MCP SDK for Go 1.7.0
Last reviewed Sep 24, 2026
Prompt Details
Prompt Composition
2prompts
- Go 1.27130 lines · 5.5K tokens
- MCP SDK for Go 1.7.063 lines · 3.3K tokens
Total193 lines · 8.8K tokens
CWE Coverage
- 15
- 20
- 22
- 59
- 78
- 79
- 89
- 94
- 117
- 190
- 201
- 208
- 209
- 250
- 252
- 257
- 287
- 295
- 306
- 307
- 311
- 319
- 323
- 327
- 338
- 345
- 347
- 352
- 362
- 367
- 378
- 426
- 444
- 488
- 494
- 522
- 532
- 639
- 732
- 759
- 770
- 772
- 807
- 862
- 863
- 915
- 916
- 918
- 942
- 1004
- 1275
- 1395
Prompt Preview
Apply the Go 1.27 baseline first. Use github.com/modelcontextprotocol/go-sdk v1.7.0 APIs with a supported, patched Go toolchain; its Go 1.25.0 module minimum is not a support guarantee. These rules cover MCP 2026-07-28 and the SDK's legacy protocol compatibility paths.
Handlers and access control
- Register only required tools, resources, templates, prompts, and custom methods. Enforce method and object authorization in handlers or
Server.AddReceivingMiddleware, including discovery, lists, completions, and subscriptions; hiding an item from a list does not prevent direct invocation. - Prefer generic
mcp.AddTool[In, Out]with narrow input and output types. It applies schema defaults and validates inputs before dispatch and typed output before returning it. Supply explicit bounds and allowed values inTool.InputSchema; review defaults as actual handler inputs. AnOuttype ofanyomits the inferred output schema. - When using low-level
Server.AddToolwithToolHandler, explicitly decode and validatereq.Params.Argumentsand validate returned structured content against the declared output schema. This API supplies neither input nor output validation. Keep custom MCP parsers consistent with the SDK's case-sensitive decoding and patched JSON dependency. - Validate prompt arguments and resource-template variables before use. A registered resource URI or matching template only selects a handler; enforce tenant ownership and the Go baseline's filesystem or outbound-network restrictions on the actual destination.
- Keep a shared
Serverregistry free of