home / skills / git-fg / thecattoolkit / integrating-mcp

This skill guides secure MCP integration for Claude Code plugins, enabling sandboxed code execution, selective tool exposure, and efficient connection

npx playbooks add skill git-fg/thecattoolkit --skill integrating-mcp

Review the files below or copy the command above to add this skill to your agents.

Files (9)
SKILL.md
2.6 KB
---
name: integrating-mcp
description: "Provides comprehensive MCP integration guidance for Claude Code plugins. MUST Use when integrating databases via MCP, setting up MCP servers, or configuring connections. Do not use for API integration, web services, or general database access."
---

# MCP Integration for Claude Code Plugins

Integrate external services into Claude Code plugins using Model Context Protocol (MCP). MCP servers provide secure, structured access to databases, APIs, and other services through a standardized interface.



#### 1. Code Execution Pattern (Recommended)
Instead of direct tool calls, **expose code APIs** rather than tool call definitions:

```json
{
  "mcpServers": {
    "code-exec": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-code-exec"],
      "env": {
        "SANDBOX_PATH": "/tmp/sandbox"
      }
    }
  }
}
```

**Benefits:**
- Give Claude a sandbox execution environment with filesystem
- Let Claude write code to make tool calls
- Elegant, prompt-on-demand pattern (similar to skills)
- Reduces token overhead

#### 2. Selective Tool Exposure
Only expose essential tools:

```json
{
  "mcpServers": {
    "minimal-db": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres"],
      "env": {
        "MCP_TOOLS": "query,schema"
      }
    }
  }
}
```

#### 3. Connection Management
- **Pool connections** to reuse
- **Lazy load** servers only when needed
- **Disconnect** inactive servers

---

## Database Integration

### Quick Reference

**1. Choose Database Type and Configure**
- PostgreSQL: `@modelcontextprotocol/server-postgres`
- MySQL: `@modelcontextprotocol/server-mysql`
- SQLite: `@modelcontextprotocol/server-sqlite`

**2. Set Environment Variables**
```bash
export POSTGRES_URL="postgresql://user:pass@host:5432/db?sslmode=require"
```

**3. Add to settings.json**
```json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres", "${POSTGRES_URL}"]
    }
  }
}
```

---



---

## Resources

### References
- **[references/mcp-configuration.md](references/mcp-configuration.md)**: Master configuration guide.
- **[references/security.md](references/security.md)**: Security best practices.
- **[references/performance.md](references/performance.md)**: Performance tuning.
- **[references/schema-management.md](references/schema-management.md)**: Schema operations.

### Examples
- **[examples/postgres-config.json](examples/postgres-config.json)**: PostgreSQL configuration.
- **[examples/multi-db-config.json](examples/multi-db-config.json)**: Multiple database setup.

Overview

This skill provides focused guidance for integrating databases and services into Claude Code plugins via the Model Context Protocol (MCP). It explains recommended MCP server patterns, secure connection setup, and practical configuration examples for PostgreSQL, MySQL, and SQLite. Use this guidance to create reliable, minimal, and secure MCP integrations specifically for Claude Code plugin environments.

How this skill works

The skill describes how to define MCP servers in plugin settings and how to run server processes that expose controlled APIs to the model. It recommends a code-exec pattern where Claude writes and runs code in a sandboxed execution server, and shows how to selectively expose only necessary tools (query, schema) to reduce surface area. It also covers connection management techniques like pooling, lazy loading, and disconnecting idle servers to optimize performance and resource usage.

When to use it

  • Setting up a PostgreSQL, MySQL, or SQLite data backend for a Claude Code plugin via MCP.
  • Configuring MCP server processes in settings.json for secure model access to a database.
  • Exposing only limited database tools (e.g., query, schema) to reduce risk and token overhead.
  • Implementing sandboxed code execution so Claude can generate and run code against services.
  • Managing long-lived connections with pooling and lazy server startup to save resources.

Best practices

  • Prefer the code-exec MCP server to give Claude a controlled sandbox and minimize token usage.
  • Limit MCP tools to the minimal set required (e.g., query,schema) to reduce attack surface.
  • Store connection strings and secrets in environment variables rather than in config files.
  • Pool database connections and close inactive servers to prevent resource leaks.
  • Only start MCP servers on demand (lazy load) and monitor them for failures and latency.

Example use cases

  • Configure a PostgreSQL MCP server in settings.json to let Claude run safe read/write queries.
  • Run an MCP code-exec server so Claude can generate migration scripts and apply them in a sandbox.
  • Expose only schema and query tools for a reporting plugin that must not run arbitrary commands.
  • Set up a multi-database MCP configuration to route analytics queries to a read-replica.
  • Lazy-start an MCP server when a user asks for database-backed insights, then disconnect after idle time.

FAQ

Can I use MCP guidance here for general web APIs or non-MCP connections?

No. This guidance is specific to MCP integration for Claude Code plugins and is not intended for generic API or web service integration.

Where should I put database credentials?

Keep credentials in environment variables and reference them from your MCP server configuration; avoid embedding secrets in checked-in config files.