MCP SDK for Go 1.8.0

Last reviewed Oct 25, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. Go 1.27130 lines · 5.5K tokens
  2. 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.AddTool and restrictive input and output schemas. If using Server.AddTool, validate arguments and outputs yourself; its raw ToolHandler does 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.TokenInfo or 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, CallTool results, and InputResponses as 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-selected ClientSession.CallTool takes effect.
  • Validate and encode MCP text, StructuredContent, EmbeddedResource, and ResourceLink values 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