-
Notifications
You must be signed in to change notification settings - Fork 2
Deployment Patterns
Different ways to assemble the generated code into a deployable binary. The full set of patterns (with code) lives in docs/usage-patterns.md — this page is the index.
One binary per upstream API, launched by the MCP host (Claude Desktop, VS Code, Cursor, Inspector) over stdio.
raw, s := gosdk.NewServer("petstore-mcp", "1.0.0")
petmcp.RegisterSwaggerPetstoreClient(s, client)
_ = raw.Run(context.Background(), &mcp.StdioTransport{})Same generated code, different transport. Used when the upstream API isn't reachable from the user's laptop, or the MCP server should be deployed once and shared.
handler := mcp.NewStreamableHTTPHandler(func(*http.Request) *mcp.Server { return raw }, nil)
log.Fatal(http.ListenAndServe(":8080", handler))Generated code is transport-agnostic — it only calls runtime.MCPServer.AddTool.
Change one import and one constructor line. No regeneration. See MCP Backends.
Run the same API twice (e.g. staging vs prod) in one MCP server, distinguished by tool-name prefix:
petmcp.RegisterSwaggerPetstoreClient(s, stagingClient, runtime.WithNamePrefix("staging"))
petmcp.RegisterSwaggerPetstoreClient(s, prodClient, runtime.WithNamePrefix("prod"))Call several Register* functions from one main:
petmcp.RegisterSwaggerPetstoreClient(s, petClient)
billmcp.RegisterBillingAPIClient(s, billClient)
auditmcp.RegisterAuditAPIClient(s, auditClient)Auth lives in the HTTP client you pass to the Register* function. Bearer tokens, mTLS, dynamic credentials — all handled at the oapi-codegen layer:
client, _ := pet.NewClientWithResponses(url,
pet.WithRequestEditorFn(func(_ context.Context, req *http.Request) error {
req.Header.Set("Authorization", "Bearer "+freshToken())
return nil
}),
)Inject tenant IDs, correlation tokens, or environment selectors that the LLM provides on every call. See Runtime Options.
Point -spec at a directory and emit one tool set per spec. See Batch Mode.
The rest (custom retry loops, OpenTelemetry tracing, request signing, audit logging) live in docs/usage-patterns.md.
Repo · Releases · Issues · Discussions · Apache 2.0
Get started
Modes
Features
Deploy
Reference
Project