MCP servers
An MCP server you write is deployed beside your agents by the same elan deploy, into its own pod with its own image, egress and allowlist. Your agents call it with no URL and no credential, and if you make it public, so can anything outside the project.
Writing one
elan new mcp tide-tables scaffolds mcp_servers/tide_tables/server.py and declares it in elan.yaml. The file exports a MANIFEST and a build() that returns a FastMCP server, of whichever FastMCP you like:
from fastmcp import FastMCP
MANIFEST = {
"slug": "tide-tables",
"version": "0.1.0", # bump it whenever this file changes
"display_name": "Tide Tables",
"description": "Tide times for our agents.",
"auth": "platform", # or "server": see below
}
def build(ctx) -> FastMCP:
"""Return the server. No I/O here: the build calls this offline."""
server = FastMCP("Tide Tables")
@server.tool()
def high_tide(port: str) -> str:
"""The next high tide at a port."""
...
return server- Dependencies go in
mcp_servers/pyproject.toml, not the repository's root one. MCP servers are built into an image without the agent runtime, so they may use a FastMCP the agents could not. build(ctx)orbuild(). The context carries the server's slug, its path, itspublic_urland itspublic_origin, which a server that checks its own tokens needs.- No I/O in
build. The build runs it with no network to list your tools. Open connections inside a tool. elan validatereads theMANIFESTwithout running the server, so write it out as a dict orMcpServerManifest(...)with plain values.
Declaring it
targets:
tide-tables:
expose: project # or public
resources: {cpu: "250m", memory: "512Mi"}
scaling: {minReplicas: 1, maxReplicas: 2}
egress:
- host: api.tides.example # this server's own allowlist, HTTPS only
secrets:
- {name: tides-api-key, env: TIDES_API_KEY}- Warm by default: one replica, always on. Scaling to zero is opt-in.
- Its own egress. The hosts under
egress:are this server's alone. The project's agents cannot reach them, and it cannot reach theirs. HTTPS only: a rule naming a port is refused. - No model, no database, no files unless you ask for the last two. An
llm:block is refused: a server that calls a model API declares that host underegress:and its key undersecrets:. - Several servers can share one pod as a group, but a group never mixes servers with agents.
Calling it from your agents
An agent names the server by slug, with no URL and no egress rule:
tools=[ToolBinding(kind="mcp", ref="tides", server="tide-tables",
tool_filter=["high_tide"])]The call goes to the platform's MCP gateway inside the cluster, which admits only this project's own agents and tells the server which run and which user the call is for. The details, including a caller's credential for a server that checks its own, are in Building an agent.
Calling it from outside
expose: public puts the server on the platform's API host, at the path its agents already use:
https://<api host>/mcp/<tenant>/<project>/<server>
A server that is not public does not exist from outside: it answers 404, exactly as a path naming nothing does. Who may call a public one is the auth in its MANIFEST:
| auth | A caller sends | The server sees |
|---|---|---|
platform | A token minted for that one server: the server's Connect panel in the console, elan mcp token <server>, or POST /v1/token with grant_type=client_credentials and resource=<the URL above>. It lasts an hour and works nowhere else. | No token. It sees X-Agentkit-Caller: external and the token's holder in X-Agentkit-Subject. |
server | Whatever your own authorization server issues. | The caller's Authorization header, untouched. A token this platform issued is refused before it arrives. |
A server that checks its own tokens configures its verifier with the URL it is given. A public one that configures none is refused at deploy, because anybody could call it:
from fastmcp.server.auth import RemoteAuthProvider
def build(ctx) -> FastMCP:
return FastMCP("Tide Tables", auth=RemoteAuthProvider(
token_verifier=my_verifier(),
authorization_servers=["https://auth.example.com"],
# FastMCP adds this server's own path to it, so pass the ORIGIN.
base_url=ctx.public_origin,
))- A client that calls without a credential is answered 401 naming the server's metadata, as the MCP authorization spec requires. For
auth: platformthat metadata names this platform, whose token endpoint offers client credentials only. - Hosted chat apps that need an OAuth sign-in use
auth: serverwith your own authorization server for now. - Every combination — your key, your user's OAuth 2 token, people signing in from their MCP app — is worked through in MCP authentication by example.
Scaling to zero
scaling: {minReplicas: 0} lets a server sleep when nobody calls it. Every call keeps it awake; the first one after a quiet spell waits while its pod starts, held by the gateway for up to 75 seconds and then answered 503 if no pod came up. Keep a public server that must answer its first call fast warm, because a client outside the platform may give up sooner. Your own agents wait 90 seconds.
What it costs
Its pod is billed like any workload's, by what it reserves. Requests are counted per message by the gateway, and anything the gateway refuses is free:
| On a bill | What counts |
|---|---|
| MCP calls from your agents | A tool run, a resource read or a prompt fetched, by this project's agents |
| MCP calls from public clients | The same, from outside the project |
| MCP discovery from your agents | Everything else a client sends: initialize, listing tools, pings and notifications |
| MCP discovery from public clients | The same, from outside the project |
Seeing what it did
- Observability lists the project's recent MCP requests, filterable by server, outcome and caller. An agent's call links to the run that made it, and a refusal says why.
- Analytics has an MCP servers tab: requests by caller, latency per server, errors, and which tools and callers they were.
- The Inspector, on the server's own page, lists its tools, resources and prompts and calls them as you — a private server too — through the same gateway, so each call is counted and appears on Observability like an agent's.
- The server's own logs, restarts and compute are on its workload page.