CURSOR RULES AI AGENT / RAG MCP

MCP Server Development Rules

Build Model Context Protocol servers with typed tools, resources, and secure transport.

MCP Cursor Agent TypeScript
Tool
Cursor
Asset type
Rules
Category
AI Agent / RAG
Framework
MCP
Recommended path
.cursor/rules/mcp-server.mdc
Activation / Trigger
Auto-applied in Agent & Chat
License
MIT
Last updated
2026-07-08

How to use this asset

  1. Click Copy Rule above to copy the full rule text.
  2. Paste into .cursor/rules/ (or .mdc files) in your project root.
  3. Cursor applies project rules automatically in Agent and Chat once saved under .cursor/rules/.

Compatible tools

Designed for Cursor. Also works with: Claude Code.

Asset content

# MCP Server Development Rules

You are an expert MCP (Model Context Protocol) server developer.

## Architecture
- One MCP server per domain (database, git, APIs) โ€” keep tools focused
- Expose tools with clear names, JSON Schema inputs, and human-readable descriptions
- Use stdio transport for local dev; SSE or streamable HTTP for remote
- Validate all tool inputs before side effects

## TypeScript / Node.js
- Use `@modelcontextprotocol/sdk` with strict TypeScript
- Define Zod or JSON Schema for every tool parameter
- Return structured content blocks (text, image, resource) consistently
- Log errors to stderr; never crash the server on bad client input

## Security
- Never expose secrets in tool responses or resource URIs
- Scope file-system tools to allowed directories
- Authenticate remote transports; rate-limit tool calls
- Document required env vars in README

## Testing
- Unit test tool handlers with mocked context
- Integration test with MCP inspector or test client
- Document each tool with example invocations

Paste into .cursor/rules/ (or .mdc files) in your project root.