Claude Code Mastery Guide (Part 6): The Complete MCP Protocol Guide
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—capable of handling all the files you throw at it, but can't reach anything in the outside world. You can't ask it to "go fetch the details of that Issue on GitHub," can't have it "take a look at what the latest API documentation looks like," let alone "go into the database and query a record." It can only guess based on knowledge trained several months ago, while the software world changes every day.
Once connected to MCP, this wall disappears.
It begins to have "tentacles"—able to 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?—Explaining 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 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 on it, and it gains different capabilities. Just like your computer can do different things by plugging in different USB devices.
Three MCP Connection Methods
Before configuration, let's understand MCP connection methods, as this affects your installation commands later:
HTTP: Cloud MCP servers, cross-network communication
- Typical examples: GitHub, Notion, Sentry
Stdio: Local scripts, requiring direct system access
- Typical examples: Local Python scripts, database connectors
Configuring remote HTTP servers usually only requires the server name and corresponding URL address.
Backend Practice 1: Connecting GitHub MCP—"Far-Sight" for Code Management
This is the most practical configuration and the one where you can most 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 inside Claude Code without switching to a browser.
Configuration Steps:
claude mcp add --transport http github https://api.githubcopilot.com/mcp/Then, in the Claude Code session, enter /mcp and complete GitHub OAuth authentication following the prompts. After successful authentication, you can use it like this:
- "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 modification content in the description"
- "Review PR #42"
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—can be set to read-only (query only) or granted read-write permissions (create PRs, push code), entirely depending on the scope you choose during OAuth authorization.
For daily use, it's recommended to keep read-only mode, temporarily authorizing 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 the 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 access capabilities to MySQL databases, enabling LLMs to check database architecture 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: Environment variables like ALLOW_INSERT_OPERATION permission switches are recommended to be set to false in production environments, maintaining read-only mode. If you need to temporarily allow write operations (such as debugging in a safe test database), enable them separately.
Usage Examples:
You: What's the total order volume in the orders table for the past week?
Claude: [Executing SQL] A total of 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 like 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: ...
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 is cut off at training time. You're using Spring Boot 3.2, but what's in its mind might still be Spring Boot 2.x old syntax; you ask it how to write batch inserts with the latest MyBatis-Plus version, and it digs out 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 context. With it installed, Claude will actively pull the 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 an 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 API: "How to configure JWT authentication in Spring Security 6?"—Claude will pull Spring Security's latest documentation, no longer giving you 5.x outdated code.
- Precise query by version number: "What's the best practice for batch inserts in MyBatis-Plus 3.5.3?"
- Get complete code examples: Not just telling you how to use it, but also bringing official recommended implementations.
Usage Examples:
You: How to configure thread pool with @Async and @EnableAsync in Spring Boot 3.2?
Claude: [Querying through Context7] Spring Boot 3.2 recommends using ThreadPoolTaskExecutor with @Async, configuration as follows: ...
You: How to use @Builder with inheritance in Lombok 1.18.30?
Claude: [Querying through Context7] @SuperBuilder is recommended...
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 the 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 Does This Suite Include?
| Component | Tools Count | Function |
|---|---|---|
| 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 detection and security risks |
| Redis Diagnostics | 7 | Memory fragmentation rate, slow log analysis, client connections, Keyspace health |
Usage Examples:
- Diagnose JVM performance issues: "Help me analyze this thread dump file, check for deadlocks"—Claude will call JVM Diagnostics tools for automatic analysis.
- Check database slow queries: "Help me analyze MySQL's slow query log, find SQL that needs optimization"—DB Analyzer helps you locate.
- Review database migrations: "Help me check if this Flyway migration script has risks"—Migration Advisor helps you analyze lock conflicts and data loss risks.
If you don't want to install the full suite at once, you can also install individual components separately, such as installing 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 the previously mentioned benborla/mcp-server-mysql (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 database types. It also supports JBang directly downloading example databases (such as Chinook, Northwind) from URLs for quick experience.
Quick Summary: Java Backend MCP Configuration Checklist
| MCP Service | One-Sentence Explanation | Configuration Priority |
|---|---|---|
| GitHub MCP | Directly operate Issues, PR, CI | Essential |
| MySQL MCP | Natural language database queries | Essential |
| Context7 MCP | Real-time documentation to prevent obsolescence | 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 obviously occupy context window
- Start with GitHub + Context7—these two cover the highest frequency needs
- Add as needed based on your actual workflow
Security Red Lines
MCP's power is built on security boundaries. The greater the capability, the more you need to control yourself.
Red Line 1: Only Install Trusted Servers
Prioritize official, open-source, community-common ones. Don't touch suspicious sources.
Red Line 2: Understand Each MCP Server's Data Access Scope
GitHub Server can see your repositories, database Server can read data in tables. Think clearly before authorization: What does it need? Can it be smaller?
Red Line 3: Production Databases Get Read-Only Permissions Only
If you need to connect MCP to query production databases, be sure to use read-only accounts. Never give write permissions to places AI can reach—one wrong DELETE statement is enough to give you a headache.
Red Line 4: Use --scope to Control MCP's 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 ...Use --scope local for project-specific MCPs (such as databases for specific projects), and --scope user for general-purpose ones (such as Context7 documentation queries).
Don't blindly install everything globally.
In one sentence: Trust should be graded, permissions should be controlled, think thrice before write operations.
Final Thoughts
MCP's core idea is simple: Don't let AI work only from memory—connect it to the external world.
You don't need to install all MCPs at once. Start from where it hurts most:
- Frequently check GitHub? → Install GitHub MCP
- Frequently query databases? → Install MySQL MCP + DB Analyzer
- Claude always uses outdated API? → 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 another "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—helping more people discover MCP, this underestimated capability.