Claude Code Mastery Guide (Part 6): Complete MCP Protocol Guide
Introduction: From Local Assistant to Internet Platform
This is the sixth part of the Claude Code Mastery Guide. In the previous part, we configured an expert team for Claude Code. In this part, we'll equip it with external devices, transforming it from a local assistant into an internet platform.
A vivid analogy: Claude Code without MCP configuration is like a genius locked in a room.
It's smart, efficient—can handle all the files you throw at it, but can't reach anything in the outside world. You can't ask it to "go grab the details of that Issue on GitHub," can't ask it to "take a look at what the latest API documentation looks like," let alone "go into the database and check a record." It can only guess based on knowledge trained months ago, while the software world changes every day.
Once connected to MCP, this wall disappears.
It gains "tentacles"—can directly read discussions on GitHub, browse the latest versions of official documentation in real-time, connect to your database to execute queries, and even converse with your project management tools and monitoring platforms.
This isn't just adding a few features—it's an essential leap from offline assistant to online collaboration platform.
What is MCP?—Explained in 30 Seconds with "USB Interface" Analogy
MCP stands for Model Context Protocol, an open-source standard launched by Anthropic in late 2024.
The name sounds intimidating, but the core concept is extremely simple. Here's an analogy:
USB Analogy
USB is the standard interface for computers connecting peripherals. Keyboards, mice, USB drives, webcams—as long as they follow the USB protocol, they work when plugged in. You don't need to install different drivers for each brand of mouse.
MCP is the standard interface for AI connecting external tools. GitHub, databases, browsers, documentation queries—as long as they follow the MCP protocol, they work when connected. AI doesn't need to write a set of integration code for each tool.
Before MCP appeared, AI tools connecting to external services was a "every man for himself" nightmare—each tool needed to develop different adapters for different platforms, with extremely high maintenance costs. MCP adds a middle layer between AI tools and external resources, unifying communication standards.
Claude Code is an MCP client. You install different MCP Servers, and it gains different capabilities. Just like your computer can do different things when you plug in different USB devices.
Three MCP Connection Methods
Before configuration, understand MCP connection methods—this affects your installation commands later:
1. HTTP Transport
Cloud-based MCP servers with cross-network communication.
Typical Examples: GitHub, Notion, Sentry
Configuration: Usually just requires server name and corresponding URL address.
claude mcp add --transport http github https://api.githubcopilot.com/mcp/2. Stdio Transport
Local scripts requiring direct system access.
Typical Examples: Local Python scripts, database connectors
Configuration: Requires command to execute the server locally.
claude mcp add mysql -- npx -y @benborla29/mcp-server-mysql3. SSE (Server-Sent Events)
Streaming connections for real-time updates.
Typical Examples: Real-time monitoring, live data feeds
Configuration: Requires SSE endpoint URL.
Backend Practice 1: Connecting GitHub MCP—"Far-Sight" for Code Management
This is the most practical configuration that lets you intuitively feel MCP's power.
GitHub officially provides an MCP Server, allowing Claude Code to directly read GitHub Issues, create PRs, check CI status, and search code repositories. You can even complete the entire PR review process in Claude Code without switching to browser.
Configuration Steps
claude mcp add --transport http github https://api.githubcopilot.com/mcp/Then, in Claude Code session, enter /mcp and complete GitHub OAuth authentication following the prompts.
Usage Examples
After authentication, you can use commands like:
"Help me check the 3 most recent open issues in the repo"
"Create a PR with title 'fix: Fix order status update bug', include my changes in description"
"Review PR #42"
"Search for code related to authentication in the codebase"
"Show me the CI status for the main branch"Permission Control: Read-Write vs. Read-Only
Note that GitHub MCP supports OAuth 2.0 authentication. Users can precisely control Claude Code's access permissions to repositories:
- Read-Only: Only query operations
- Read-Write: Create PRs, push code
This entirely depends on the scope you select during OAuth authorization.
Recommendation: For daily use, maintain read-only mode. Temporarily authorize write operations only when needed.
Backend Practice 2: Connecting MySQL MCP—"Direct Dialogue" with Database
This is the scenario where backend developers can most intuitively feel the "efficiency leap." Previously, to query a database, you had to manually open client, write SQL, copy results, paste to Claude—now just say one sentence.
The most mature and popular choice in the community is benborla/mcp-server-mysql, a Node.js-based MCP implementation providing MySQL database access capabilities, enabling LLMs to check database schema and execute SQL queries.
Configuration Steps (One Command)
claude mcp add mysql \
-e MYSQL_HOST=localhost \
-e MYSQL_PORT=3306 \
-e MYSQL_USER=root \
-e MYSQL_PASSWORD=your_password \
-e MYSQL_DATABASE=your_database \
-e ALLOW_INSERT_OPERATION=false \
-e ALLOW_UPDATE_OPERATION=false \
-e ALLOW_DELETE_OPERATION=false \
-- npx -y @benborla29/mcp-server-mysql⚠️ Special Reminder: For production environments, set permission switches like ALLOW_INSERT_OPERATION to false, maintaining read-only mode. Only enable write operations separately when needed (e.g., debugging in safe test databases).
Usage Examples
You: What's the total order count in the orders table for the past week?
Claude: [Executing SQL] 1,284 orders were created in the past week.
You: Help me check the structure of the product table
Claude: [Querying table structure] The product table has fields: id, name, price, stock, etc. Price is DECIMAL(10,2) type.
You: Which customers have order amounts exceeding 1000?
Claude: [Executing SQL] There are 47 customers, list as follows: ...Security Best Practices
- Use Read-Only Accounts: Create dedicated database users with minimal permissions
- Limit Database Scope: Only grant access to specific databases needed
- Audit Queries: Enable query logging to track AI database interactions
- Never Use Root: Always use principle of least privilege
Practice 3: Installing Context7 MCP Server
One of the most awkward problems with AI tools is—training data has a cutoff date.
Claude Code's knowledge cuts off at training time. You're using Spring Boot 3.2, but it might still have Spring Boot 2.x old syntax in mind; you ask about MyBatis-Plus latest version's batch insert, it gives you 2022 old usage that errors on compilation.
Context7 is here to plug this hole. It's a documentation platform providing real-time, versioned library documentation and code examples, directly injected into AI's context. With it installed, Claude will actively fetch latest official documentation when answering library-related questions, no longer guessing from memory.
Configuration Steps (One Command)
claude mcp add --transport http context7 https://mcp.context7.com/mcpIf you use it heavily, you can also add API Key (optional):
claude mcp add --transport http context7 https://mcp.context7.com/mcp \
--header "CONTEXT7_API_KEY: YOUR_API_KEY"What Can You Do After Configuration?
Check Latest APIs:
- "How to configure JWT authentication in Spring Security 6?"
- Claude fetches latest Spring Security documentation, no longer giving you 5.x outdated code.
Precise Version Queries:
- "What's the best practice for batch insert in MyBatis-Plus 3.5.3?"
Get Complete Code Examples:
- Not just tells you how to use, but also brings official recommended implementations.
Usage Examples
You: How to configure thread pool with @Async and @EnableAsync in Spring Boot 3.2?
Claude: [Querying via Context7] Spring Boot 3.2 recommends ThreadPoolTaskExecutor with @Async, configuration as follows: ...
You: How to use @Builder with inheritance in Lombok 1.18.30?
Claude: [Querying via Context7] Recommends using @SuperBuilder...Recommended Installation Checklist
There are hundreds of MCP Servers in the community, but you don't need to install them all. Based on daily development needs, here are recommendations:
MCP Java Backend Suite (All-in-One Solution)
This is currently the most comprehensive MCP toolkit in Java backend field, packaging 5 independent MCP servers together. 35 tools cover database analysis, JVM diagnostics, migration risks, Spring Boot monitoring, and Redis diagnostics. One installation, one configuration—no need to separately struggle with 5 packages and 5 configuration files.
Installation Command:
npm install -g mcp-java-backend-suiteThen Generate Configuration:
npx mcp-java-backend-suite configWhat This Suite Includes
| Component | Tools | Functionality |
|---|---|---|
| DB Analyzer | 9 | PostgreSQL/MySQL/SQLite schema analysis, index optimization, query plans, slow query detection, table relationship analysis |
| JVM Diagnostics | 6 | Thread dump analysis, deadlock detection, GC log parsing, heap histogram analysis, heap memory comparison |
| Migration Advisor | 6 | Flyway/Liquibase migration script risk analysis, lock detection, data loss detection, rollback SQL generation |
| Spring Boot Actuator | 7 | Health, Metrics, Environment, Beans, Startup, Cache analysis, automatic problem and security risk detection |
| Redis Diagnostics | 7 | Memory fragmentation ratio, slow log analysis, client connections, Keyspace health |
Usage Examples
Diagnose JVM Performance Issues:
"Help me analyze this thread dump file, check for deadlocks"
→ Claude calls JVM Diagnostics tool for automatic analysisCheck Database Slow Queries:
"Help me analyze MySQL slow query log, find SQL needing optimization"
→ DB Analyzer helps locateReview Database Migrations:
"Help me check if this Flyway migration script has risks"
→ Migration Advisor analyzes lock conflicts and data loss risksIf you don't want to install the full suite at once, you can install individual components separately, like Spring Boot Actuator alone:
claude mcp add mcp-spring-boot-actuator -- npx -y mcp-spring-boot-actuatorJDBC MCP Server (Universal Database Interface)
This is an officially released JDBC standard MCP server supporting almost all relational databases including PostgreSQL, MySQL, MariaDB, SQLite, Oracle, etc. It enables LLMs to check, query, and even modify database content—just provide a JDBC URL.
Start with JBang in One Line:
jbang jdbc@quarkiverse/quarkus-mcp-servers jdbc:mysql://localhost:3306/yourdbWhy Recommend It? Compared to benborla/mcp-server-mysql mentioned earlier (focused on MySQL), JDBC MCP Server has broader coverage. One configuration covers all JDBC-compatible databases, suitable for complex projects needing to connect to multiple databases. It also supports JBang directly downloading example databases (like Chinook, Northwind) from URLs for quick experience.
Quick Summary: Java Backend MCP Configuration Checklist
| MCP Service | One-Sentence Explanation | Priority |
|---|---|---|
| GitHub MCP | Directly operate Issues, PR, CI | Essential |
| MySQL MCP | Natural language database queries | Essential |
| Context7 MCP | Real-time documentation prevents outdated info | Essential |
| Java Backend Suite | 35-tool "family bucket" | Strongly Recommended |
| JDBC MCP | One configuration connects all databases | As Needed |
| Arthas MCP | Java application real-time diagnostics | As Needed |
Installation Principles
- Don't Install Too Many at Once: More than 10 MCPs will noticeably consume context window
- Start with GitHub + Context7: These two cover highest-frequency needs
- Add Based on Actual Workflow: Install according to your specific needs
Security Red Lines
MCP's power is built on security boundaries. With great power comes great responsibility.
Red Line 1: Only Install Trusted Servers
Prioritize official, open-source, community-common servers. Don't touch unknown sources.
Trusted Sources:
- Official MCP servers from known companies
- Well-maintained open-source projects with active communities
- Servers recommended by trusted community members
Warning Signs:
- No source code available
- No clear maintainer information
- Requests excessive permissions
- Negative community feedback
Red Line 2: Understand Each MCP Server's Data Access Scope
GitHub Server can see your repositories, Database Server can read table data. Before authorization, think clearly: What does it need? Can it be more minimal?
Permission Audit Checklist:
- What data can this server access?
- What operations can it perform?
- Is this scope necessary for my use case?
- Can I use more restrictive permissions?
Red Line 3: Production Databases Get Read-Only Permissions Only
If connecting MCP to query production databases, always use read-only accounts. Never give write permissions to places AI can reach—one wrong DELETE statement is enough to give you a nightmare.
Production Database Security:
# Create dedicated read-only user
CREATE USER 'claude_readonly'@'%' IDENTIFIED BY 'strong_password';
GRANT SELECT ON your_database.* TO 'claude_readonly'@'%';
FLUSH PRIVILEGES;
# Use this user in MCP configuration
-e MYSQL_USER=claude_readonly
-e MYSQL_PASSWORD=strong_passwordRed Line 4: Use --scope to Control MCP Effective Range
# Project-level: Only available in current project (recommended)
claude mcp add github --scope local ...
# User-level: Available in all projects
claude mcp add github --scope user ...Guidelines:
- Use
--scope localfor project-specific MCPs (like specific project databases) - Use
--scope userfor general-purpose ones (like Context7 documentation queries)
Don't blindly install everything globally.
One-Sentence Summary
Trust must be tiered, permissions must be constrained, think thrice before write operations.
Other Notable MCP Servers
Filesystem MCP
Access local files securely:
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystemUse Cases:
- Read configuration files
- Process log files
- Generate reports
Security: Configure allowed directories only
Playwright MCP
Browser automation:
claude mcp add playwright -- npx -y @modelcontextprotocol/server-playwrightUse Cases:
- Web scraping
- UI testing
- Screenshot capture
Git MCP
Git operations:
claude mcp add git -- npx -y @modelcontextprotocol/server-gitUse Cases:
- Repository analysis
- Commit history queries
- Branch management
Final Thoughts
MCP's core idea is simple: Don't let AI work only from memory—give it connections to the external world.
You don't need to install all MCPs at once. Start from your biggest pain points:
- Frequently check GitHub? → Install GitHub MCP
- Frequently query databases? → Install MySQL MCP + DB Analyzer
- Claude always uses outdated APIs? → Install Context7 MCP
- Frequently troubleshoot JVM issues? → Install JVM Diagnostics or Arthas MCP
- Frequently do database migrations? → Install Migration Advisor
Each additional MCP gives your Claude Code one more "superpower." And all this requires just one line: claude mcp add.
If this article made you realize Claude Code's potential goes far beyond "writing code," welcome to like, watch, and share—help more people discover this underestimated capability of MCP.
Resources:
- MCP Official Documentation: https://modelcontextprotocol.io/
- MCP Server Directory: https://github.com/modelcontextprotocol/servers
- Claude Code MCP Guide: https://docs.anthropic.com/claude-code/mcp