mcp-agent-patterns
Skill27 starsChanged 3 months agoApache-2.0View on GitHub
Use when integrating or optimizing Model Context Protocol (MCP) servers and clients. Keywords: MCP, Model Context Protocol, tool discovery, lazy loading, sampling, resource subscription, MCP server.
In this repository163 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-memorySkill
- claukitSkill
- multi-agent-orchestrationSkill
- workflow-state-machinesSkill
- ai-multimodalSkill
- geo-fundamentalsSkill
- media-processingSkill
- screenshotSkill
- seo-fundamentalsSkill
- soraSkill
- aestheticSkill
- figma-implement-designSkill
- figmaSkill
- frontend-designSkill
- mobile-designSkill
- tailwind-patternsSkill
- ui-stylingSkill
- agentic-ragSkill
- api-patternsSkill
- app-builderSkill
- architectureSkill
- ask-mattSkill
- aspnet-coreSkill
- backend-developmentSkill
- better-authSkill
- clean-codeSkill
- code-agent-patternsSkill
- codebase-designSkill
- code-review-checklistSkill
- code-reviewSkill
- context-engineeringSkill
- context-optimizationSkill
- database-designSkill
- databasesSkill
- diagnoseSkill
- diagnosing-bugsSkill
- docs-seekerSkill
- domain-modelingSkill
- frontend-dev-guidelinesSkill
- graph-ragSkill
- i18n-localizationSkill
- implementSkill
- improve-codebase-architectureSkill
- lint-and-validateSkill
- llm-evalsSkill
- nextjs-best-practicesSkill
- nodejs-best-practicesSkill
- openai-docsSkill
- performance-profilingSkill
- playwright-interactiveSkill
- playwrightSkill
- prompt-engineeringSkill
- prototypeSkill
- python-patternsSkill
- react-patternsSkill
- render-deploySkill
- repomixSkill
- researchSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
When a server needs LLM intelligence (e.g., parsing unstructured output or making a decision):
- Very specific: line 37
Use URI Templates (res://server/type/{id}) to create flexible resource paths.
- Distinctive: line 49
Server Sandboxing: Run MCP servers in isolated containers or limited-permission processes.
- Distinctive: line 53
Contract Verification: Ensure MCP server implementations conform to the JSON-RPC message schema.
- Distinctive: line 54
Context Hygiene: Verify that only relevant tools/resources are included in the prompt.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MCP Agent Patterns (Model Context Protocol)
Overview
The Model Context Protocol (MCP) provides a standardized way for AI agents to interact with external tools, data resources, and environments. This skill defines architectural patterns and implementation best practices for building, connecting, and optimizing MCP-based systems within the KILO-KIT ecosystem.
When To Use
- Implementing custom MCP servers or clients.
- Integrating external services (APIs, DBs, filesystems) as MCP servers.
- Optimizing context windows when dealing with large tool catalogs.
- Implementing real-time resource synchronization or complex multi-server orchestrations.
- Security-critical integrations requiring isolated execution environments.
Core MCP Concepts
- Tools: Executable functions exposed to the LLM.
- Resources: Data sources that can be read by the LLM (e.g., file contents, database records).
- Prompts: Reusable templates or workflows designed to be used by the LLM.
- Sampling: A protocol allowing an MCP server to request the host client to perform LLM inference on its behalf, enabling agentic tool behavior.
Advanced Patterns
Dynamic Tool Catalog & Progressive Loading
To prevent token bloat:
- Manifest Exposure: Expose only essential, high-level tool definitions initially.
- On-Demand Loading: Load detailed JSON Schemas only when a tool is selected or explicitly requested by the agent context.
MCP Sampling Protocol
When a server needs LLM intelligence (e.g., parsing unstructured output or making a decision):
- The server issues a
sampling/createMessagerequest to the client. - The client acts as the host/gateway, maintaining control over the model selection and cost.
Resource Streaming & Subscriptions
- Use URI Templates (
res://server/type/{id}) to create flexible resource paths. - Implement Resource Subscriptions to push data updates from the server to the client without polling.
Eager vs Lazy Tool Registration
- Eager: Best for small sets of essential core tools (zero-latency startup).
- Lazy: Mandatory for large or dynamic catalogs to keep initial prompts lean.
Multi-Server Orchestration
- Namespace Routing: Prefix tool names with server aliases (
serverA:toolX). - Conflict Resolution: Implement a central router to handle collisions between tools of the same name across different servers.
Security Considerations
- Server Sandboxing: Run MCP servers in isolated containers or limited-permission processes.
- Credential Isolation: Inject sensitive environment variables (API keys, tokens) only into the specific server process that requires them. Use a secure configuration store (e.g., HashiCorp Vault) for production deployments.
Quality Gates
- Contract Verification: Ensure MCP server implementations conform to the JSON-RPC message schema.
- Context Hygiene: Verify that only relevant tools/resources are included in the prompt; prune dormant subscriptions.
- Error Handling: Standardize error codes for common failures (e.g., timeout, auth denied, connection lost).
MCP 2.0 Features (2025-2026)
- OAuth 2.0 Auth: Native support for delegated access without sharing long-lived keys.
- Elicitation API: Interactive flow where the client helps the user provide missing inputs for a tool call.
- Structured Tool Results: Formalized response types beyond simple strings (e.g., rich content types, UI components).
References
- MCP Official Documentation
- JSON-RPC 2.0 Specification
- KILO-KIT MCP Integration Best Practices
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

