go-mcp

go-mcp is a cursor rule for Cursor from dstotijn/mcp-origin. It costs 0 tokens per session (939 once invoked), scanned A, a copy of go-mcp, Apache-2.0.

Development rules for building Go applications that expose tools through MCP, a standard way for AI assistants to use external tools.

In plain words
What is it for?
They help developers create MCP servers in Go, register tools, document parameters, support different connection methods, and return text or images.
Why use it?
They provide consistent guidance for starting the server, defining tool inputs, handling errors, returning results, and shutting down safely.

Cursor rule for Cursor

Install

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.

agentmods
npx agentmods add rules/dstotijn/mcp-origin/go-mcp
Clone the repo
git clone --depth 1 https://github.com/dstotijn/mcp-origin

Made for: Cursor.

Wrote 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.

agentmods badge for go-mcp

README.md
[![agentmods](https://agentmods.dev/badge/rules/dstotijn/mcp-origin/go-mcp.svg)](https://agentmods.dev/rules/dstotijn/mcp-origin/go-mcp)
Your own site
<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>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 939 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 95% copy Near-identical to another mod in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 4d ago against content hash 15b257ba987a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

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.

Origin

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.

.cursor/rules/go-mcp.mdc · 136 lines

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

  1. Use mcp.NewServer() with appropriate configuration options to create a new MCP server
  2. Configure transports based on requirements (stdio, HTTP/JSON-RPC, SSE)
  3. Always handle graceful shutdown of the server
  4. Use context for cancellation and timeouts
  5. Register all tools before starting the server

Tool Implementation

  1. Define tool parameters as Go structs with JSON tags
  2. Add descriptive comments to struct fields for parameter documentation
  3. Use mcp.CreateTool() to create new tools with proper definitions
  4. Focus on business logic in tool handlers (validation is automatic)
  5. Return appropriate mcp.CallToolResult objects with clear content

Content Types

  1. Use appropriate content types (mcp.TextContent, mcp.ImageContent, etc.)
  2. Structure complex responses using multiple content objects
  3. Set the IsError flag when returning error results
  4. Use helper functions for common response patterns

Context Handling

  1. Pass context through to all tool handlers
  2. Respect context cancellation in long-running operations
  3. Use context timeouts for external API calls
  4. Add appropriate values to context when needed

Error Handling

  1. Return error results rather than panicking
  2. Provide clear, user-friendly error messages
  3. Include relevant details in error messages
  4. Use helper functions for creating error responses

Testing

  1. Write unit tests for tool handlers
  2. Mock external dependencies in tests
  3. Test both success and error cases
  4. 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

Read the full file on GitHub · 136 lines

Changes

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.

  1. 4d ago First seen · 136 lines · 939 tokens per session scan A 15b257ba987a

Subscribe to this mod's changes

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.