CREATE MCP SERVER¶
Creates a new MCP (Model Context Protocol) server or replaces an existing MCP server.
- See also:
Syntax¶
Parameters¶
nameString that specifies the identifier for the MCP server; must be unique for the schema in which the MCP server is created.
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$$Specifies the YAML specification defining the tools and configuration for the MCP server.
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
For
GENERICandCORTEX_AGENT_RUNtools, you can also specify an optionalannotationsobject with MCP tool behavior hints:readOnlyHint: Iftrue, the tool doesn’t modify its environment.destructiveHint: Iftrue, the tool might perform destructive updates. This hint is meaningful only whenreadOnlyHintisfalse.idempotentHint: Iftrue, repeated calls with the same arguments have the same effect as one call.openWorldHint: Iftrue, the tool might interact with external entities.
Each annotation is optional. For omitted annotations, Snowflake uses the default for the tool type. The defaults for
GENERICandCORTEX_AGENT_RUNarereadOnlyHint: false,destructiveHint: true,idempotentHint: false, andopenWorldHint: true.Tool annotations are hints for MCP clients. They don’t enforce tool behavior or replace access control. Configure privileges for the underlying object according to the actual operations that the tool can perform.
Supported tool types:
CORTEX_SEARCH_SERVICE_QUERY: Cortex Search Service toolCORTEX_ANALYST_MESSAGE: Cortex Analyst toolSYSTEM_EXECUTE_SQL: SQL execution toolCORTEX_AGENT_RUN: Cortex Agent toolCODING_AGENT: Coding Agent tool, with no stored agent object. Snowflake adds thecode_toolset_alltool on every runGENERIC: Custom tool for UDFs and stored procedures
Tool-specific requirements:
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
For
CODING_AGENTtools:- Add the tool to the server specification. Omit
identifier. This tool does not reference a stored agent object. config: Optional agent configuration, such asmodel,instructions,tools,tool_resources, andskills. Leavemessages,thread_id,parent_message_id,stream,background, andorigin_applicationout ofconfig. See Coding Agent.- Snowflake appends
code_toolset_allafter any tools inconfig. A run can includecode_toolset_allorcode_execution, but not both.
Access control requirements¶
A role used to execute this operation must have the following privileges at a minimum:
| Privilege | Object |
|---|---|
| CREATE MCP SERVER | Schema |
| USAGE | Schema |
For tools that reference other objects, additional privileges are required:
| 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.
Usage notes¶
- 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. -
External OAuth authorization-server binding and advertised scopes aren’t set in the MCP server specification. Configure them with the
OAUTH_AUTHORIZATION_SERVERandOAUTH_SCOPES_SUPPORTEDparameters on the enclosing account, database, or schema. For details, see Configure External OAuth authentication for MCP servers. -
The MCP server specification is stored as metadata and can be viewed using DESCRIBE MCP SERVER.
-
Multiple tools can be defined in a single MCP server specification.
-
Tool names must be unique within a single MCP server.
-
Regarding metadata:
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.
Examples¶
Example 1: Create MCP server with Cortex Search and Analyst tools
Example 2: Create MCP server with SQL execution tool
Example 3: Create MCP server with custom UDF tool
Example 4: Create MCP server with custom stored procedure tool
Example 5: Create MCP server with Agent tool
Example 6: Create MCP server with a coding agent tool
Add a CODING_AGENT tool to the server specification. Clients call the tool with a text argument and can pass thread_id to continue the conversation.