mcp-patterns_skill

This skill helps you build and integrate MCP server patterns for Claude Code, enabling tool hosting, resource exposure, and robust server workflows.
  • Shell

8

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill 0xdarkmatter/claude-mods --skill mcp-patterns

  • SKILL.md4.5 KB

Overview

This skill provides practical Model Context Protocol (MCP) server patterns for building integrations with Claude Code. It bundles example server code, project layout guidance, and configuration snippets to help you expose tools and resources to Claude via MCP. Use these patterns to implement reliable tool handlers, resource endpoints, auth, and state management for production or development servers.

How this skill works

The skill inspects common MCP server workflows and gives ready-to-use patterns: tool registration (list_tools), tool invocation (call_tool), and resource handling. It includes examples for running a Python MCP server over stdio or via a process manager (uv), plus recommended project layout, configuration fragments for Claude Desktop, and quick-reference patterns for validation, auth, caching, and testing. Common issues and solutions are documented to speed troubleshooting.

When to use it

  • Building a custom MCP server to expose tools to Claude Code
  • Validating and sanitizing tool inputs before execution
  • Adding resources (static or dynamic) accessible to the model
  • Implementing auth using environment variables or token refresh
  • Persisting state or caching tool results for faster responses

Best practices

  • Define strict input schemas (JSON Schema / Pydantic) for each tool to avoid runtime errors
  • Return well-formed MCP content arrays from call_tool (text or structured blocks)
  • Run the server under a supervisor (uv or similar) for stable process management
  • Store secrets in environment variables referenced by your MCP config, not in shell profiles
  • Add timeouts and async patterns for network calls to prevent server-wide stalls

Example use cases

  • Search tool: register a search tool with query input and return formatted results
  • CRUD tools: expose create/read/update/delete handlers for an internal DB via multiple tools
  • Resource exposure: provide static config or dynamic DB-backed resources to the model
  • Auth wrapper: implement API-key or OAuth token refresh and surface tokens as resources
  • Testing: write pytest-async tests for tool handlers and a manual script for quick validation

FAQ

Ensure list_tools returns a valid JSON schema and that the MCP server process is started with the command configured in Claude Desktop; check server logs for schema errors.

What should call_tool return?

call_tool should return an MCP content array, typically objects like {type: "text", text: "..."}; follow the MCP spec for other content types.

How do I handle auth securely?

Load secrets from environment variables set in the Claude Desktop MCP server config and implement token refresh logic with TTL for OAuth flows.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
mcp-patterns skill by 0xdarkmatter/claude-mods | VeilStrat