CREATE MCP SERVER¶
创建一个新的 MCP(模型上下文协议)服务器或替换现有的 MCP 服务器。
- See also:
语法
参数
name指定 MCP 服务器标识符的字符串;对于在 MCP 服务器中创建任务的架构必须是唯一的。
In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example,
"My object"). Identifiers enclosed in double quotes are also case-sensitive.For more information, see Identifier requirements.
FROM SPECIFICATION $$specification_yaml$$指定 MCP 服务器所使用的工具和配置的 YAML 规范。
The specification must include a
toolsarray with one or more tool definitions. Each tool must specify:name: Unique identifier for the tooltype: Tool type (see supported tool types)title: Human-readable title for the tooldescription: Description of what the tool does
支持的工具类型:
CORTEX_SEARCH_SERVICE_QUERY: Cortex Search Service toolCORTEX_ANALYST_MESSAGE: Cortex Analyst toolSYSTEM_EXECUTE_SQL: SQL execution toolCORTEX_AGENT_RUN: Cortex Agent toolGENERIC: Custom tool for UDFs and stored procedures
特定于工具的要求:
For
CORTEX_SEARCH_SERVICE_QUERY,CORTEX_ANALYST_MESSAGE, andCORTEX_AGENT_RUNtools:identifier: Fully qualified name of the underlying object (for example,database.schema.object_name)
For
GENERICtools:identifier: Fully qualified name of the UDF or stored procedureconfig: Configuration object specifying:type: Eitherfunction(for UDF) orprocedure(for stored procedure)warehouse: Warehouse to use for executioninput_schema: JSON schema defining the function/procedure parameters
访问控制要求
A role used to execute this operation must have the following privileges at a minimum:
| Privilege | Object |
|---|---|
| CREATE MCP SERVER | Schema |
| USAGE | Schema |
对于引用其他对象的工具,需要额外的权限:
| Privilege | Object |
|---|---|
| USAGE | Cortex Search Service (for CORTEX_SEARCH_SERVICE_QUERY tools) |
| SELECT | Semantic View (for CORTEX_ANALYST_MESSAGE tools) |
| USAGE | Cortex Agent (for CORTEX_AGENT_RUN tools) |
| USAGE | User-defined function or stored procedure (for GENERIC tools) |
| USAGE | Warehouse (for GENERIC tools) |
Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema.
For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.
For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
使用说明
- The OR REPLACE and IF NOT EXISTS clauses are mutually exclusive. They can’t both be used in the same statement.
-
CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.
-
CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.
-
When configuring hostnames for MCP server connections, use hyphens (
-) instead of underscores (_). MCP servers have connection issues with hostnames containing underscores. -
The MCP server specification is stored as metadata and can be viewed using DESCRIBE MCP SERVER.
-
可以在单个 MCP 服务器规范中定义多个工具。
-
工具名称在单个 MCP 服务器中必须是唯一的。
-
关于元数据:
Attention
Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.
示例
示例 1:创建具有 Cortex Search 和 Analyst 工具的 MCP 服务器
示例 2:创建具有 SQL 执行工具的 MCP 服务器
示例 3:创建具有自定义 UDF 工具的 MCP 服务器
示例 4:创建具有自定义存储过程工具的 MCP 服务器
示例 5:创建具有代理工具的 MCP 服务器