Skip to content

docs(connections): document gating MCP tools by name or input#329

Open
bensabic wants to merge 2 commits into
mainfrom
docs/mcp-tool-approval-gating
Open

docs(connections): document gating MCP tools by name or input#329
bensabic wants to merge 2 commits into
mainfrom
docs/mcp-tool-approval-gating

Conversation

@bensabic

Copy link
Copy Markdown

Documents how to gate specific MCP connection tools behind human approval — by tool name or by tool input — instead of putting every call behind always(). The new "Gate specific tools by name or input" section in docs/connections/mcp.mdx shows a custom approval policy and calls out the two connection-specific details: the qualified <connection>__<tool> name format (match the bare name with .includes()/.endsWith()), and that toolInput is untyped and may be undefined.

import { defineMcpClientConnection } from "eve/connections";

// Bare tool names whose effects are irreversible — always gate these.
const DELETE_TOOLS = ["delete_draft", "delete_thread"];
// Tools that can publish — gate only when the call schedules a post.
const PUBLISH_TOOLS = ["create_draft", "edit_draft"];

// Read `requestBody.publish_at` without trusting the input's shape.
const publishesNow = (input: unknown): boolean => {
  const body = (input as { requestBody?: { publish_at?: unknown } })?.requestBody;
  return typeof body?.publish_at === "string" && body.publish_at.length > 0;
};

export default defineMcpClientConnection({
  url: "https://mcp.example.com/mcp",
  description: "Social publishing: draft, schedule, and manage posts.",
  auth: { getToken: async () => ({ token: process.env.SOCIAL_API_KEY! }) },
  approval: ({ toolName, toolInput }) => {
    if (DELETE_TOOLS.some((t) => toolName.includes(t))) return "user-approval";
    if (PUBLISH_TOOLS.some((t) => toolName.includes(t))) {
      return publishesNow(toolInput) ? "user-approval" : "not-applicable";
    }
    return "not-applicable";
  },
});

Expand the MCP connections approval section with a custom-policy example
that gates only specific remote tools — by qualified tool name and by
tool input — instead of every call. Notes the connection-specific
qualified name format (<connection>__<tool>) and that toolInput is
untyped and may be undefined.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
eve-docs Ready Ready Preview, Comment, Open in v0 Jun 26, 2026 4:36am

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.

1 participant