Request a demo
← All articles
MCP

Serving context over MCP to your agents

Published contexts become MCP tools at /mcp, so Claude Code, Claude Desktop, Cursor, VS Code and your own agents call governed answers with one key.

· 6 min read · For AI platform teams and engineering leads

Every team building agents is wiring them to data, and most are doing it one integration at a time: a connector here, a hand-written tool there, a service account with too much access underneath. The Model Context Protocol gives agents a standard way to discover and call tools. InsightCompose uses it to serve the one thing agents most need and most often get wrong: governed, fresh context from your warehouses.

This post covers how published contexts become MCP tools, how an agent connects, and what happens on every call. It continues our context management series.

Contexts as tools

When a context is published in InsightCompose, it becomes available as a tool on the product's MCP server at /mcp. No separate integration is written. The context's declaration already contains everything a tool needs:

A published context, as an agent sees itThe context's title, phrasings and freshness become the tool description; its typed parameters become the tool's input schema. The agent reads what it can call, and with what.One context, seen as a toolPublished contextsales.book.open_by_stageparams: days, product_linephrasings, columnsfreshness: cached 15 minpublishedMCP toolname: sales_book_open_by_stagedescription: title + phrasings + freshnessinput schema: days 1-365, product_line enumoutput: typed rows + as_of + masked flag
The context's title, phrasings and freshness become the tool description; its typed parameters become the tool's input schema. The agent reads what it can call, and with what.
  • Name and description. The tool's name comes from the context key; its description combines the title, the example phrasings and the freshness promise, so an agent knows both what the tool answers and how current the answer is.
  • Input schema. The typed parameters, with their defaults, bounds and allowed values, become a JSON schema. A well-behaved client will not even offer an out-of-range value; if one arrives anyway, the layer refuses it with the field name.
  • Output. Typed rows with labels and units, plus as_of, the freshness promise, whether the result was truncated and whether masking applied.

Because the tool list is the list of published contexts the caller is allowed to see, an agent never sees a tool it cannot call. Retire a context and its tool disappears; publish a new version and the tool reflects it.

Connecting an agent

The Connect an agent panel in the product gives copy-ready setup for the common MCP clients: Claude Code, Claude Desktop, Cursor and VS Code, plus a generic configuration for your own agents. It shows the endpoint for your deployment and lets an administrator mint a key with the right scopes. The examples below use placeholder hosts and keys.

Claude Code

claude mcp add --transport http insightcompose https://compose.your-company.com/mcp \
  --header "Authorization: Bearer $INSIGHTCOMPOSE_KEY"

Clients that read an mcpServers file

{
  "mcpServers": {
    "insightcompose": {
      "type": "http",
      "url": "https://compose.your-company.com/mcp",
      "headers": { "Authorization": "Bearer ${INSIGHTCOMPOSE_KEY}" }
    }
  }
}

Keep the key in an environment variable or your client's secret store rather than in the file. For clients and environments that prefer a local process, the server also runs over stdio, either directly or as a thin proxy to your deployment, so a desktop client can talk to a local command that forwards to the governed endpoint.

Interactive clients can sign in instead. Alongside API keys, the server accepts OAuth 2.1 tokens from your identity provider. It publishes the standard protected-resource metadata, so a client that supports it can discover where to sign in, and the agent then acts as the person who signed in, with that person's scope.

What happens on every call

An MCP server that simply forwards tool calls to a database is a faster way to leak data. The InsightCompose server puts every call through one guarded path, the same pattern our platform uses for its catalog MCP server:

How an agent's tool call reaches a contextEvery MCP client talks to one endpoint. Each tool call passes the same guarded path: identify the principal, check the tool's scope, rate-limit, resolve the tenant, run the context, then redact, cap and audit the result.Claude CodeClaude DesktopCursorVS CodeYour agent/mcpStreamable HTTPor stdioGuarded path, every callprincipal: key or OAuthscope for this toolrate limittenant scoperun the contextredact, size cap, auditContextsDatabricksSnowflakePostgresSQL Server
Every MCP client talks to one endpoint. Each tool call passes the same guarded path: identify the principal, check the tool's scope, rate-limit, resolve the tenant, run the context, then redact, cap and audit the result.
  1. Principal. The bearer token is resolved to a principal: an API key or an OAuth identity. No token, or an invalid one, gets a 401 with the header that tells a client how to authenticate.
  2. Scope per tool. Each tool requires a scope, and a key holds only the scopes it was granted. A key minted for one team's contexts cannot call another team's.
  3. Rate limit. Each key has a rate limit, so a looping agent slows down instead of hammering the warehouse.
  4. Tenant scope. The principal resolves to an organization, a book and a data-class ceiling. The server never accepts a request for another organization's data.
  5. Run the context. The context runs exactly as it would over REST: parameters validated and bound, row scope from the caller, read-only, statement timeout, row cap, masking for callers without clearance, served from cache when the freshness promise allows.
  6. Redaction and size cap. The result is redacted against the caller's ceiling and capped in size, so one call cannot flood a model's context window or carry more than it should.
  7. Audit. One audit row per call: principal, tool, a hash of the arguments, status, size and timing.

The server is stateless, so any replica can answer any request, and it sits behind the same network controls as the rest of your deployment.

Why not let the agent write SQL?

Agents can write SQL, and InsightCompose has a guarded SQL engine for open-ended questions. But for the questions your business asks every day, a tool that calls a reviewed context is better in every way that matters to an enterprise:

Agent writes SQLAgent calls a context
DefinitionRe-derived on each questionReviewed once, versioned
ScopeWhatever the connection seesThe caller's book and organization
Personal dataSeen, then hopefully withheldMasked before it leaves the server
FreshnessUnknown to the agentas_of on every answer
CostUnboundedBounded parameters, timeout, row cap, cache
AuditA query log, if anyWho, which context and version, what came back

The agent still decides which context to call and with what parameters. That is the part models are good at. The definition, the scope and the safeguards stay with the layer.

Calling external MCP servers too

MCP runs in both directions. Besides serving contexts, InsightCompose can register external MCP servers, for example a ticketing system or a document store, as sources for its own assistant and insights. Those calls go through a registry with per-server allow-lists of tools, approval for tools that write, egress checks on every endpoint, result size limits and an audit row per call. Tool results are treated as data, capped and redacted, and never executed as instructions.

Getting started

Publish one context, mint a key scoped to it, paste the configuration into Claude Code or Cursor, and ask the agent the question in your own words. You will see it pick the tool, fill in the parameters and quote the answer with its as_of. The MCP for agents page has the details, and the docs list every field. If you would rather see it on your own data first, ask us for a working session.

Where people stay in charge

An administrator decides which agents may connect, by minting keys and granting scopes per tool, and can revoke a key at any time. Data owners decide which contexts are published, and so which tools exist. The agent decides only which published tool to call and which allowed values to pass. Every call is audited with the principal behind it, so a person can see exactly what each agent asked for, and what it was given.

See your own context layer, on your data

Bring one source and three questions your agents or apps need answered. We will stand up governed contexts over them in your environment and connect an agent to them in a working session.

We reply within one business day. Next comes a 45-minute executive briefing for your CIO or CDO, then, if it fits, a 12-week Innovation POD in your environment.