Skip to main content

Optional Column

The tool_policy column on mcp_sessions is optional. The SDK only writes it when you explicitly provide a toolPolicy on the session object. If you never set a policy, no migration is needed โ€” the SDK works without the column.

Without the Column

If you donโ€™t run the tool_policy migration:
  • sessions.create() omits tool_policy from the INSERT
  • sessions.update() omits tool_policy from the UPDATE unless you pass it
  • sessions.get() and sessions.list() return toolPolicy: undefined, which the SDK treats as mode: 'all'

With the Column

Uncomment the tool_policy column in the install schema when you want to persist policies: Neon โ€” migrations/neon/20260513010000_install_mcp_sessions.sql:
Supabase โ€” migrations/supabase/20260330195700_install_mcp_sessions.sql:
Run npx mcp-ts neon-init or npx mcp-ts supabase-init (or apply the migration manually) after uncommenting.

Adding tool_policy to an existing database

If you already have sessions and want to add tool policy support later, the same SQL works for both Neon and Supabase:
This adds the column and backfills existing sessions with the unrestricted all policy.

Setting a Policy

Pass toolPolicy when creating or updating a session:

Enforcing Policies at Runtime

Use the ToolPolicyGateway โ€” it wraps a client and enforces the sessionโ€™s policy before every tool call:
The gateway also filters listTools() results to only return allowed tools.