mcp-claude-desktop-guide
Comprehensive guide to MCP (Model Context Protocol) with Claude Desktop configuration examples for GitHub and Supabase integration
GitHubスター
1
ユーザー評価
未評価
フォーク
0
イシュー
0
閲覧数
0
お気に入り
0
MCP (Model Context Protocol) Complete Guide
Welcome to the comprehensive guide for Model Context Protocol (MCP) with Claude Desktop integration examples. This repository provides everything you need to understand MCP, configure Claude Desktop, and connect to services like GitHub and Supabase.
Table of Contents
- What is MCP?
- JSON-RPC Protocol
- Claude Desktop Configuration
- GitHub Integration
- Supabase Integration
- Complete Configuration Example
- Troubleshooting
- Resources
What is MCP?
Model Context Protocol (MCP) is an open standard that enables secure connections between AI assistants (like Claude) and external data sources and tools. It allows Claude to interact with various services through a standardized interface.
Key Features
- Standardized Communication: Uses JSON-RPC 2.0 for client-server communication
- Secure: Built-in authentication and authorization mechanisms
- Extensible: Supports custom tools and data sources
- Real-time: Enables live data access and tool execution
- Bidirectional: Allows both data retrieval and action execution
How MCP Works
┌─────────────┐ JSON-RPC ┌─────────────┐ HTTP/API ┌─────────────┐
│ Claude │ ◄────────────► │ MCP Server │ ◄────────────► │ External │
│ (Client) │ │ │ │ Service │
└─────────────┘ └─────────────┘ └─────────────┘
- Claude acts as the MCP client
- MCP Server translates between MCP protocol and external service APIs
- External Service (GitHub, Supabase, etc.) provides the actual functionality
JSON-RPC Protocol
MCP uses JSON-RPC 2.0 for communication. Here's how the protocol works:
Request Format
{
"jsonrpc": "2.0",
"id": "unique-request-id",
"method": "tools/call",
"params": {
"name": "github:create_repository",
"arguments": {
"name": "my-new-repo",
"description": "A new repository",
"private": false
}
}
}
Response Format
Success Response:
{
"jsonrpc": "2.0",
"id": "unique-request-id",
"result": {
"content": [
{
"type": "text",
"text": "Repository created successfully"
}
]
}
}
Error Response:
{
"jsonrpc": "2.0",
"id": "unique-request-id",
"error": {
"code": -32000,
"message": "Repository already exists",
"data": {
"details": "A repository with this name already exists"
}
}
}
Common Methods
initialize
- Establish connectiontools/list
- Get available toolstools/call
- Execute a toolresources/list
- Get available resourcesresources/read
- Read resource content
Claude Desktop Configuration
Claude Desktop uses a configuration file to define MCP server connections. The configuration file location varies by operating system:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
Basic Configuration Structure
{
"mcpServers": {
"server-name": {
"command": "path-to-executable",
"args": ["arg1", "arg2"],
"env": {
"ENV_VAR": "value"
}
}
}
}
GitHub Integration
Prerequisites
- GitHub Personal Access Token with appropriate permissions
- MCP GitHub Server (typically
@modelcontextprotocol/server-github
)
Installation
npm install -g @modelcontextprotocol/server-github
Configuration
Add this to your claude_desktop_config.json
:
{
"mcpServers": {
"github": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_TOKEN_HERE"
}
}
}
}
Environment Variables
Create a .env
file or set these environment variables:
# Replace with your actual GitHub token
GITHUB_PERSONAL_ACCESS_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GitHub Token Permissions
Your GitHub token needs these scopes:
repo
- Full repository accessworkflow
- GitHub Actions workflow accessread:org
- Organization read accessuser:email
- Email access
Supabase Integration
Prerequisites
- Supabase Project with API credentials
- MCP Supabase Server (typically
@modelcontextprotocol/server-supabase
)
Installation
npm install -g @modelcontextprotocol/server-supabase
Configuration
Add this to your claude_desktop_config.json
:
{
"mcpServers": {
"supabase": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-supabase"
],
"env": {
"SUPABASE_URL": "YOUR_SUPABASE_PROJECT_URL",
"SUPABASE_ANON_KEY": "YOUR_SUPABASE_ANON_KEY"
}
}
}
}
Environment Variables
# Replace with your actual Supabase credentials
SUPABASE_URL=https://your-project-id.supabase.co
SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Finding Your Supabase Credentials
- Go to your Supabase Dashboard
- Select your project
- Go to Settings → API
- Copy:
- Project URL →
SUPABASE_URL
- Project API keys →
anon/public
→SUPABASE_ANON_KEY
- Project URL →
Complete Configuration Example
Here's a complete claude_desktop_config.json
file with both GitHub and Supabase:
{
"mcpServers": {
"github": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
},
"supabase": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-supabase"
],
"env": {
"SUPABASE_URL": "https://your-project-id.supabase.co",
"SUPABASE_ANON_KEY": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InlvdXItcHJvamVjdC1pZCIsInJvbGUiOiJhbm9uIiwiaWF0IjoxNjc3NTU2ODAwLCJleHAiOjE5OTMxMzI4MDB9.your-signature-here"
}
},
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/path/to/allowed/directory"
]
},
"brave-search": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-brave-search"
],
"env": {
"BRAVE_API_KEY": "BSA_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}
Available MCP Servers
Here are some popular MCP servers you can add:
File System Access
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/allowed/path"]
}
Web Search (Brave)
"brave-search": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
"env": {
"BRAVE_API_KEY": "YOUR_BRAVE_API_KEY"
}
}
Slack Integration
"slack": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-slack"],
"env": {
"SLACK_BOT_TOKEN": "xoxb-your-bot-token",
"SLACK_TEAM_ID": "YOUR_TEAM_ID"
}
}
PostgreSQL Database
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"POSTGRES_CONNECTION_STRING": "postgresql://user:password@localhost:5432/dbname"
}
}
Troubleshooting
Common Issues
1. MCP Server Not Found
# Install the MCP server globally
npm install -g @modelcontextprotocol/server-github
2. Authentication Errors
- Verify your API tokens are correct
- Check token permissions/scopes
- Ensure environment variables are properly set
3. Configuration File Location Make sure you're editing the correct config file:
# macOS
~/Library/Application Support/Claude/claude_desktop_config.json
# Windows
%APPDATA%\Claude\claude_desktop_config.json
4. JSON Syntax Errors
- Use a JSON validator to check your configuration
- Ensure proper comma placement
- Check for missing quotes
Testing Your Configuration
- Restart Claude Desktop after making configuration changes
- Check the Tools Menu in Claude Desktop - you should see new tools
- Test a Simple Command like asking Claude to list your GitHub repositories
Debug Mode
Enable debug mode by adding to your configuration:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your-token",
"DEBUG": "mcp:*"
}
}
}
}
Security Best Practices
- Never commit tokens to version control
- Use environment variables for sensitive data
- Limit token permissions to minimum required scopes
- Regularly rotate API tokens
- Monitor usage of your API tokens
Resources
Official Documentation
MCP Servers Repository
Community Resources
Contributing
Found an issue or want to improve this guide? Please:
- Fork this repository
- Create a feature branch
- Submit a pull request
License
This guide is provided under the MIT License. Feel free to use, modify, and distribute.
Happy coding with MCP and Claude Desktop! 🚀
For questions or support, please open an issue in this repository.