YouTip LogoYouTip

Claude Code Mcp

If we consider Claude Code an excellent typist (code generation) and tester (code verification), then adding MCP (Model Context Protocol) gives Claude true external senses and limbsβ€”it is no longer limited to the code files in the current project, but can actively connect to external world resources and tools, becoming your full-chain development collaboration partner. !(#) ### What is MCP (Model Context Protocol)? MCP is an open standardized protocol launched by Anthropic, specifically designed to address the core pain points of AI collaboration with external tools. The core logic of MCP overturns traditional approaches: instead of having AI learn the usage rules of all tools one by one, all tools provide a unified interface to AI. This logic is like a universal power outlet in the real worldβ€”no need to adapt appliances to different outlets; as long as the outlet has a unified standard, all appliances can be used directly. After connecting to an MCP server, you can have Claude Code: * Fetch requirements from JIRA/ticket systems and develop features, create GitHub PRs * Analyze Sentry monitoring data, locate production environment errors * Query data from databases like PostgreSQL/MySQL * Update code based on Figma designs, automatically generate email drafts, etc. !(#) ### Why Does Claude Code Need MCP? Before MCP, Claude Code's capabilities were strictly limited to the project folder you currently have open, like an assistant who can only see what is in front of them, unable to perceive any information outside the project. The emergence of MCP completely breaks this information island, allowing Claude to deeply participate in the full development process: Here are a few intuitive scenario comparisons to quickly understand the value of MCP: | Scenario | Without MCP | With MCP | | --- | --- | --- | | Cross-repository analysis | Can only analyze code within the current folder, unable to link other repositories | Cross-repository collaboration: "Help me analyze the API documentation of repository A, then write the corresponding calling method in repository B" | | Requirements/discussion sync | You need to manually copy and paste requirement documents and team discussion records to the chat | Real-time sync collaboration information: "Check the discussion records in the Slack #feature-x channel to see everyone's modification suggestions for this feature" | | Database verification | Cannot directly verify code and database compatibility, can only manually check table structures | Direct database integration: "Go check the structure of the users table in MySQL and the first 5 pieces of data to determine if my user query API matches" | | Automation workflows | Can only generate code snippets for you to manually copy and use | Automated execution: "Help me write a browser automation script and execute it via MCP using Puppeteer to verify the interaction logic of the login page" | Simply put, MCP transforms Claude Code from a passive information-receiving assistant into a proactive information-obtaining, action-executing collaboration partner. * * * ## Basic Usage of MCP in Claude Code Claude Code has built-in complete MCP management capabilities, with only one core command: claude mcp Common subcommands: | Command | Function | | --- | --- | | `claude mcp add` | Add an MCP server | | `claude mcp list` | View all configured servers | | `claude mcp get ` | View details of a specific server | | `claude mcp remove ` | Delete a server | | `/mcp` | View status/authentication in Claude Code | * * * ## Installing MCP Servers MCP servers support three connection methods: HTTP/SSE/stdio. HTTP is recommended (SSE is deprecated). ### 1. Remote HTTP Server (Recommended) Suitable for cloud service tools, this is the most common method: # Basic syntax claude mcp add --transport http # Example 1: Connect to Notion claude mcp add --transport http notion https://mcp.notion.com/mcp # Example 2: HTTP server with authentication claude mcp add --transport http secure-api https://api.example.com/mcp --header "Authorization: Bearer your-token" ### 2. Remote SSE Server (Deprecated) Only compatible with older tools, prefer HTTP as a replacement: # Basic syntax (for compatibility only) claude mcp add --transport sse # Example: Connect to Asana claude mcp add --transport sse asana https://mcp.asana.com/sse ### 3. Local stdio Server Suitable for tools requiring local system access (such as local databases, custom scripts): # Basic syntax (note: parameters before -- are Claude parameters, after -- are server commands) claude mcp add --transport stdio -- # Example: Connect to Airtable (replace with your own API key) claude mcp add --transport stdio --env AIRTABLE_API_KEY=your-key airtable -- npx -y airtable-mcp-server > Key note: Parameters like `--transport` and `--env` must be placed **before** the server name. `--` is used to separate Claude parameters from server commands to avoid parameter conflicts. ## Managing MCP Servers After configuration, you can manage servers with the following commands: # List all configured servers claude mcp list # View details of a specific server (e.g., github) claude mcp get github # Delete a specific server claude mcp remove github # Check server status in Claude Code /mcp * * * ## Configuration Scope (Controlling Server Visibility) You can specify the scope of MCP servers to adapt to personal/team usage scenarios: | Scope | Purpose | Configuration Command Example | | --- | --- | --- | | local (default) | Only available for current project, private configuration (e.g., sensitive keys) | `claude mcp add --scope local ...` | | project | Team sharing (stored in .mcp.json, can be committed to version control) | `claude mcp add --scope project ...` | | user | Available for all projects (personal global configuration) | `claude mcp add --scope user ...` | > Priority: local > project > user (for servers with the same name, local configuration overrides shared configuration) ## Practical Examples ### Example 1: GitHub Code Review claude mcp add --transport http github https://api.githubcopilot.com/mcp/ In Claude Code: > Review PR #456 and suggest improvements > Show me all open PRs assigned to me ### Example 2: Sentry Production Environment Troubleshooting claude mcp add --transport http sentry https://mcp.sentry.dev/mcp > /mcp # Complete OAuth login > What are the most common errors in the last 24 hours? ### Example 3: Direct PostgreSQL Query claude mcp add --transport stdio db -- npx -y @bytebase/dbhub --dsn "postgresql://readonly:pass@prod.db.com:5432/analytics" > Show me the schema for the orders table > Which users haven't purchased in 90 days? * * * ## Advanced Ways to Use MCP in Conversations ### 1. Using @ to Reference MCP Resources > Analyze @github:issue://123 and suggest a fix Supports comparison of multiple resources: > Compare @postgres:schema://users with @docs:file://user-model ### 2. MCP Prompt as Slash Commands MCP can expose commands: /mcp__github__list_prs /mcp__jira__create_issue "Login bug" high Claude will execute them like built-in commands. * * * ## Key Notes 1. **Authentication**: Remote MCP servers (like GitHub/Sentry) require OAuth 2.0 authorization by executing `/mcp` in Claude Code; 2. **Windows Compatibility**: For local stdio servers using npx, you need to add `cmd /c` wrapper (e.g., `-- cmd /c npx -y package-name`), otherwise a "Connection closed" error will occur; 3. **Third-party Risk**: When using non-official MCP servers, verify the source is trustworthy to avoid prompt injection/security risks; 4. **Parameter Order**: When configuring stdio servers, parameters before and after `--` cannot be swapped, otherwise execution will fail.
← Vue3 Taskhub TaskClaude Code Cli β†’