Skip to content

feat(mcp): reach hosted servers through a url and headers in mcp.yaml - #1757

Merged
edenreich merged 1 commit into
mainfrom
feat/mcp-hosted-servers
Nov 8, 2026
Merged

edenreich merged 1 commit into
mainfrom
feat/mcp-hosted-servers

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Resolves #1755

Summary

A hosted MCP server such as AgentMail (https://mcp.agentmail.to/mcp, authenticated with an x-api-key header) could not be configured. A server entry built its endpoint from scheme, host, port and path, and nothing could carry a request header.

This replaces the per-thread mcp_servers on the resume_conversation frame that #1754 asked for. The server is configuration of the machine the agent runs on, not a field a client sends with every thread open. #1754 is closed with the rationale.

servers:
  - name: agentmail
    enabled: true
    url: https://mcp.agentmail.to/mcp
    headers:
      x-api-key: ${AGENTMAIL_API_KEY}

Changes

  • config/mcp.go:
    • MCPServerEntry gains url and headers, and GetURL returns url when it is set.
    • UnresolvedHeaders names the headers whose expanded value is empty.
  • internal/protocols/mcp/infrastructure/client.go: NewClient takes the headers and sends them on every request. They are set before the protocol headers, so they never override Content-Type, Accept or the MCP headers.
  • internal/protocols/mcp/supervisor.go: an enabled server with an unresolved header is skipped with a warning. No client is made for it and no container is started, so a process without the credential starts without that server instead of failing discovery.
  • Docs: the per-server field table and a Hosted Servers section in docs/mcp-integration.md, and one line in the mcp README.

Verification

  • Tests cover GetURL with url, UnresolvedHeaders, the client sending configured headers without overriding protocol ones, and the supervisor skip.
  • The skip test fails when the StartServers guard is removed.
  • go test -race passes on the touched packages, go test ./... passes, and so do the pre-commit hook and lint.

Docs follow-up: inference-gateway/docs#1128.

A server entry accepts `url`, replacing the endpoint built from scheme, host, port and path, and `headers`, sent on every request under the protocol's own headers. `${VAR}` expansion keeps the credential in the environment of the process that loads the file, so a daemon's workers get it from the machine the agent runs on.

An enabled server whose expanded header is empty is skipped with a warning and no container is started for it, so a process without the credential starts without that server instead of failing discovery.

Closes #1755
@edenreich
edenreich requested a review from a team as a code owner November 8, 2026 14:38
@github-project-automation github-project-automation Bot moved this to Todo in 2026 Nov 8, 2026
@edenreich
edenreich merged commit d69b73e into main Nov 8, 2026
1 check passed
@edenreich
edenreich deleted the feat/mcp-hosted-servers branch November 8, 2026 14:58
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.248.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

released Shipped in a release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] Hosted MCP servers: url and headers in mcp.yaml

1 participant