Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/dstotijn/mcp-origin/go-mcpgit clone --depth 1 https://github.com/dstotijn/mcp-originWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/dstotijn/mcp-origin/go-mcp)<a href="https://agentmods.dev/rules/dstotijn/mcp-origin/go-mcp"><img src="https://agentmods.dev/badge/rules/dstotijn/mcp-origin/go-mcp.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00939 |
| Opus 5 | $0.00000 | $0.00469 |
| Sonnet 5 | $0.00000 | $0.00188 |
| Haiku 4.5 | $0.00000 | $0.00094 |
Grade A, and why
go-mcp scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
This is a copy
95% identical to go-mcp — 19 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.
How it starts
The opening of the file, as written. The whole thing — 136 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Description
This rule provides guidelines for working with the Model Context Protocol (MCP) in Go applications using the go-mcp library. MCP is a protocol for AI assistants to interact with external tools and services.
Rule
When working with MCP in Go:
MCP Server Setup
- Use
mcp.NewServer()with appropriate configuration options to create a new MCP server - Configure transports based on requirements (stdio, HTTP/JSON-RPC, SSE)
- Always handle graceful shutdown of the server
- Use context for cancellation and timeouts
- Register all tools before starting the server
Tool Implementation
- Define tool parameters as Go structs with JSON tags
- Add descriptive comments to struct fields for parameter documentation
- Use
mcp.CreateTool()to create new tools with proper definitions - Focus on business logic in tool handlers (validation is automatic)
- Return appropriate
mcp.CallToolResultobjects with clear content
Content Types
- Use appropriate content types (
mcp.TextContent,mcp.ImageContent, etc.) - Structure complex responses using multiple content objects
- Set the
IsErrorflag when returning error results - Use helper functions for common response patterns
Context Handling
- Pass context through to all tool handlers
- Respect context cancellation in long-running operations
- Use context timeouts for external API calls
- Add appropriate values to context when needed
Error Handling
- Return error results rather than panicking
- Provide clear, user-friendly error messages
- Include relevant details in error messages
- Use helper functions for creating error responses
Testing
- Write unit tests for tool handlers
- Mock external dependencies in tests
- Test both success and error cases
- Use table-driven tests for multiple scenarios
Implementation
- The Cursor IDE will enforce this rule by:
- Providing suggestions for MCP implementation
- Highlighting potential issues in MCP code
- Offering refactoring options to improve code quality
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 136 lines · 939 tokens per session scan A 15b257ba987a
go-mcp is a cursor rule published in the GitHub repository dstotijn/mcp-origin (5 stars, last pushed 1y ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 939 tokens. A static security scan graded it A with 0 findings. It is 95% identical to go-mcp, differing in 19 lines, and is treated as a copy.
Other cursor rules, from other repositories
adapter-features
Database-specific features must be implemented in the specialized adapter only. Base adapters (postgres, mysql, etc.) must remain database-agnostic.
integration-tests
Human-readable integration test requests; helpers vs httptest; suites/ vs per-DB placement.
code-style
Formatting, lint, comments language.
shared-libraries
Shared libraries - condition framework, inventory containers, file-backed DB, itinerary, references.
go
Cursor rule "go" from supertokens/create-supertokens-app, covering go and examples.
Go安全规范
Cursor rule "Go安全规范" from nongjun/awesome-harness-engineering, covering go 安全, 安全扫描, 环境变量 and context 与超时.