Skip to content

feat: support MCP Server resource (CREATE MCP SERVER) and MCP server grants#35

Open
GClunies wants to merge 1 commit into
datacoves:mainfrom
GClunies:snowcap-26
Open

feat: support MCP Server resource (CREATE MCP SERVER) and MCP server grants#35
GClunies wants to merge 1 commit into
datacoves:mainfrom
GClunies:snowcap-26

Conversation

@GClunies

Copy link
Copy Markdown
Contributor

Summary

Adds a schema-scoped mcp_server resource so Snowflake managed MCP servers can be managed declaratively instead of with hand-run SQL — where re-running CREATE OR REPLACE MCP SERVER silently drops every USAGE grant on the server. Snowflake has no ALTER MCP SERVER, so the resource diffs a canonicalized specification: an unchanged spec is a no-op plan, and only a real change emits a single CREATE OR REPLACE, with a plan-time warning that grants will be dropped (snowcap-managed grants come back on the next apply).

Closes #26

Changes

  • New MCPServer resource (mcp_servers: YAML key) with a specification property rendered as CREATE MCP SERVER <fqn> FROM SPECIFICATION $$...$$ (reuses StringProp, no new prop machinery)
  • Specification canonicalization: representation-independent across YAML config and DESC MCP SERVER's JSON server_spec (sorted keys, version defaulted to 1, YAML-only scalar types collapsed, tools sorted by name) — unit-tested against YAML 1.1 gotchas and all five tool types
  • update_mcp_server lifecycle: spec change → one CREATE OR REPLACE; rename → clear error (no ALTER exists); plan warning fires on both snowcap apply and the snowcap plan -o / apply --plan two-step workflow
  • Grants: GRANT { USAGE | MODIFY } ON MCP SERVER via on_mcp_server: or on: mcp server <fqn> (generic — zero grant.py changes); MCPServerPriv + CREATE MCP SERVER schema priv registered
  • Fetch/plan round-trip: fetch_mcp_server (SHOW + DESC, existence_only fast path) and list_mcp_servers
  • Docs: generated docs/resources/mcp_server.md, SUMMARY entry, MCP examples in grant.md
  • Tests: fixture pair (auto-swept by gitops/identity/from_sql suites), TestMCPServer, grant tests, lifecycle/warning tests — full unit suite green (1560)

Notes

  • Integration coverage (live SHOW/DESC round-trip) needs a Snowflake account with MCP servers; the normalizer's version-stamping assumption should be verified there before relying on no-op plans in production
  • Follow-up candidate: auto re-grant snowcap-managed grants in the same apply that replaces the server (plan-time injection), and test whether CREATE OR REPLACE MCP SERVER ... COPY GRANTS is supported

Snowflake managed MCP servers (CREATE MCP SERVER ... FROM SPECIFICATION)
previously had to be managed with hand-run SQL, where re-running
CREATE OR REPLACE silently drops all USAGE grants on the server.

Add a schema-scoped mcp_server resource (mcp_servers: YAML key) with a
specification property. Because Snowflake has no ALTER MCP SERVER, the
specification is canonicalized (sorted keys, version defaulted, JSON/YAML
representation-independent, tools sorted by name) so an unchanged spec
produces a no-op plan; only a real change emits a single CREATE OR REPLACE,
and the plan warns that grants on the server will be dropped - on both the
one-step apply and the plan-file two-step workflow. Renames raise a clear
error instead of emitting invalid ALTER SQL.

GRANT USAGE ON MCP SERVER works via on_mcp_server: and the multi-word
on: string form with no grant.py changes; MCPServerPriv registers
MODIFY/USAGE. fetch_mcp_server reads SHOW + DESC (server_spec) with an
existence_only fast path; list_mcp_servers enables sync/export sweeps.

Closes datacoves#26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support MCP Server resource (CREATE MCP SERVER) and MCP server grants

1 participant