Golem configure mcp server

From golemcloud/golem · View interactive version

Golem configure mcp server is an AI agent skill from the GitHub repository golemcloud/golem. Configuring MCP (Model Context Protocol) server deployments in golem.yaml. Use when the user asks to expose agents through MCP, enable MCP for an agent, add MCP server support, set up MCP authentication, or configure MCP deployments for local or cloud environments.

How to use this skill

Skill file

Configuring MCP Server Deployments

Overview

Golem agents with MCP-compatible method schemas can be automatically exposed as an MCP (Model Context Protocol) server without writing any extra code. MCP is enabled by adding an mcp section to golem.yaml — the same way HTTP API deployments are configured under httpApi.

The MCP server uses the Streamable HTTP transport. Once deployed, any MCP-compatible client (Claude Desktop, MCP Inspector, Cursor, custom clients) can connect to the server and interact with your agents through MCP tools, resources, and prompts.

Streamable HTTP describes the MCP connection; it does not make agent stream<T> values

MCP-compatible. A method is not exposed when its input or output schema recursively contains an

agent stream, including a stream nested in a record, variant, collection, or another stream. Add a

bounded stream-free adapter method if MCP clients need the same capability. Do not collect an

unbounded stream solely to bypass this limitation.

Adding an MCP Deployment

Add an mcp section to the root golem.yaml:

mcp:
  deployments:
    local:
      - subdomain: my-app  # resolves to my-app.localhost:9007 by default
        agents:
          CounterAgent: {}
          TaskAgent: {}

Structure

Define exactly one of subdomain or domain on each deployment. Prefer subdomain for built-in server: local and server: cloud environments. Use domain when you need a full custom domain. subdomain cannot be used with custom server environments — those must use domain.

Do not use localServer.mcpPort: 0 in the manifest. Port 0 is only allowed when passed directly as --mcp-port 0 to golem server run; manifest deployment domains require stable nonzero ports. The local server routes requests by matching their Host header against the expanded <subdomain>.localhost:<port>, so the running server must bind the same port the manifest expands to: golem server run warns when its --mcp-port differs from the manifest value, and such deployments are not reachable until the two match.

<subdomain>.localhost resolves only on the machine running the local server. The MCP listener defaults to worker_service.bind_address = "127.0.0.1", independently of localServer.routerAddr. External access requires a reachable domain, an appropriate worker-service bind address, and network access rules; DNS alone is insufficient. Replace all well-known default secrets before exposing MCP, HTTP, or the main API externally. The server rejects non-loopback listener addresses while any default secret remains. Changing the worker-service bind address also exposes its unauthenticated internal gRPC listener: restrict that listener with a firewall and keep other internal services on loopback. See golem-local-dev-server for configuration details.

Local Development

For local development, the MCP server listens on port 9007 by default (separate from the HTTP API gateway on port 9006). Use *.localhost:9007 domains:

mcp:
  deployments:
    local:
      - subdomain: my-app  # resolves to my-app.localhost:9007 by default
        agents:
          MyAgent: {}

After deploying with golem deploy --yes, the MCP server is available at:

http://my-app.localhost:9007/mcp

Cloud Deployment

For Golem Cloud's built-in server, configure the cloud environment and use subdomain:

mcp:
  deployments:
    local:
      - subdomain: my-app  # resolves to my-app.localhost:9007 by default
        agents:
          MyAgent: {}
    cloud:
      - subdomain: my-app  # resolves to my-app.mcps.golem.cloud
        agents:
          MyAgent:
            securityScheme: my-oauth

environments:
  local:
    server: local
  cloud:
    server: cloud

Deploy to cloud with:

golem deploy --yes --cloud

For custom DNS or custom server environments, use domain with a full domain:

mcp:
  deployments:
    prod:
      - domain: mcp.example.com
        agents:
          MyAgent:
            securityScheme: my-oauth

Agent Options

Each agent entry accepts an optional securityScheme field:

agents:
  PublicAgent: {}                          # No authentication
  SecureAgent:
    securityScheme: my-oidc                # Require OAuth authentication

Security Schemes

MCP deployments support OAuth-based authentication through security schemes. Create a security scheme using the CLI:

Creating a Security Scheme

golem api security-scheme create my-oidc \
  --provider-type google \
  --client-id "YOUR_CLIENT_ID" \
  --client-secret "YOUR_CLIENT_SECRET" \
  --redirect-url "http://my-app.localhost:9007/mcp/oauth/callback" \
  --scope openid --scope email --scope profile

For a custom OAuth provider:

golem api security-scheme create my-custom-oidc \
  --provider-type custom \
  --custom-provider-name "my-provider" \
  --custom-issuer-url "https://auth.example.com/realm" \
  --client-id "CLIENT_ID" \
  --client-secret "CLIENT_SECRET" \
  --redirect-url "http://my-app.localhost:9007/mcp/oauth/callback" \
  --scope openid --scope email --scope profile

Supported Providers

| Provider | --provider-type value |

|---|---|

| Google | google |

| Facebook | facebook |

| Microsoft | microsoft |

| GitLab | gitlab |

| Custom OIDC | custom (requires --custom-issuer-url) |

Referencing in golem.yaml

After creating a security scheme, reference it by name:

mcp:
  deployments:
    local:
      - subdomain: my-app  # resolves to my-app.localhost:9007 by default
        agents:
          SecureAgent:
            securityScheme: my-oidc

Important: The OAuth callback URL in the security scheme must match the MCP server domain. The callback path is always /mcp/oauth/callback.

Automatic MCP Mapping

Agent methods are automatically mapped to MCP entities based on these rules:

| Agent Type | Method | MCP Entity |

|---|---|---|

| Singleton | Read-only, no user-supplied parameters | Resource |

| Non-singleton | Read-only, no user-supplied parameters | Resource template |

| Any | Has user-supplied parameters, or is not marked read-only | Tool |

Tool and Resource Naming

MCP tool and resource names are constructed as {AgentTypeName}-{method_name}, where the method name preserves the source language naming convention (not kebab-case):

| Language | Method in code | MCP tool name |

|---|---|---|

| Rust | increment_by | CounterAgent-increment_by |

| TypeScript | incrementBy | CounterAgent-incrementBy |

| Scala | incrementBy | CounterAgent-incrementBy |

Constructor parameters (which identify the agent instance) are automatically included in the tool's input schema alongside the method's own parameters.

Agent and Method Metadata

Add description and prompt metadata to improve MCP discoverability:

Rust:

#[description("Increments the counter by n")]
#[prompt("Increment by a given number")]
fn increment_by(&mut self, n: u32) -> u32;

TypeScript:

incrementBy: method({
  input: { n: z.number() },
  returns: z.number(),
  description: "Increments the counter by n",
  promptHint: "Increment by a given number",
}),

Scala:

@description("Increments the counter by n")
@prompt("Increment by a given number")
def incrementBy(n: Int): Future[Int]

Both are optional and are included in the MCP metadata sent to clients.

Special Data Types for MCP

Golem supports special data types that map well to MCP concepts. These are not MCP-specific — agents using them can still be invoked through HTTP, RPC, etc.

Unstructured Text

Accept free-form text input, optionally constrained by language:

Rust:

fn summarize(&self, text: UnstructuredText) -> String;

Unstructured Binary

Accept binary data, optionally constrained by MIME type:

Rust:

#[derive(Debug, Clone, AllowedMimeTypes)]
enum Image {
    #[mime_type("image/png")] Png,
    #[mime_type("image/jpeg")] Jpeg,
}
fn process_image(&self, image: UnstructuredBinary<Image>) -> String;

Multimodal

Accept mixed text, binary, or structured data:

Rust:

fn analyze(&self, input: Multimodal) -> String;

Multi-Environment Deployments

Configure different domains and security settings per environment:

mcp:
  deployments:
    local:
      - subdomain: my-app  # resolves to my-app.localhost:9007 by default
        agents:
          MyAgent: {}
    cloud:
      - subdomain: my-app  # resolves to my-app.mcps.golem.cloud
        agents:
          MyAgent:
            securityScheme: prod-google-oidc

environments:
  local:
    server: local
  cloud:
    server: cloud

Deploying

After configuring golem.yaml, deploy. Always use --yes to avoid interactive prompts:

golem deploy --yes               # Deploy to the default environment (usually local)
golem deploy --yes --cloud       # Deploy to the cloud environment

Testing with MCP Inspector

You can verify your MCP server using the MCP Inspector:

npx @modelcontextprotocol/inspector

Then connect to http://my-app.localhost:9007/mcp using the Streamable HTTP transport.

Complete Example

# golem.yaml

mcp:
  deployments:
    local:
      - subdomain: counter-app  # resolves to counter-app.localhost:9007 by default
        agents:
          CounterAgent: {}
    cloud:
      - subdomain: counter-app  # resolves to counter-app.mcps.golem.cloud
        agents:
          CounterAgent:
            securityScheme: google-oidc

environments:
  local:
    server: local
  cloud:
    server: cloud

Key Constraints

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.