MCP SDK for Go 1.8.0
Last reviewed Oct 25, 2026
Prompt Details
Prompt Composition
2prompts
- Go 1.27130 lines · 5.5K tokens
- MCP SDK for Go 1.8.039 lines · 1.9K tokens
Total169 lines · 7.4K tokens
CWE Coverage
- 15
- 20
- 22
- 59
- 78
- 79
- 89
- 94
- 117
- 190
- 201
- 208
- 209
- 250
- 252
- 257
- 287
- 295
- 306
- 307
- 319
- 323
- 327
- 338
- 345
- 347
- 352
- 362
- 367
- 378
- 426
- 444
- 488
- 494
- 522
- 532
- 732
- 759
- 770
- 772
- 807
- 862
- 863
- 915
- 916
- 918
- 942
- 1004
- 1275
- 1395
- 1427
Prompt Preview
Apply these rules to MCP clients and servers built with github.com/modelcontextprotocol/go-sdk. Treat tool descriptions, prompts, resource contents, elicitation responses, and peer metadata as data supplied across a trust boundary.
Tools, resources, and model input
- Register typed tools with
mcp.AddTooland restrictive input and output schemas. If usingServer.AddTool, validate arguments and outputs yourself; its rawToolHandlerdoes not do the generic helper's schema validation. Check lengths, ranges, paths, URLs, and tenant identifiers before acting. - In every tool, prompt, resource, completion, and custom-method handler, authorize the current principal for the exact operation, arguments, and resource. Use
req.Extra.TokenInfoor trusted request context for identity, and scope list results and subscriptions to that principal. A tool schema, capability advertisement, or model selection never grants permission. - Treat
ClientSession.ListTools,ReadResource,GetPrompt,CallToolresults, andInputResponsesas untrusted content. Keep text from those results out of system instructions and tool authority; require an application policy and, for consequential actions, user approval before a model-selectedClientSession.CallTooltakes effect. - Validate and encode MCP text,
StructuredContent,EmbeddedResource, andResourceLinkvalues for the destination before rendering HTML, building queries, opening files, or invoking commands. Follow resource links only after validating their URI and the destination's access policy. - Limit what secrets and