Claude Code Mastery Guide (Part 6): Complete MCP Protocol Guide
Introduction: From Local Assistant to Internet Platform
This is the sixth installment of the Claude Code Mastery Guide. In the previous article, we configured an expert team for Claude Code. In this article, we'll equip it with external devices, transforming it from a local assistant into an internet-connected 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 it can't reach anything in the outside world. You can't ask it to "fetch the details of that Issue from GitHub," you can't have it "check what the latest API documentation looks like," and forget about "querying a record in the database." It can only guess based on knowledge trained months ago, while the software world changes every day.
Once connected via 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 a fundamental leap from offline assistant to online collaboration platform.
What is MCP?—Explained in 30 Seconds Using "USB Interface"
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 a standard interface for computers to connect 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 a standard interface for AI to connect 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 separate integration code for each tool.
Before MCP emerged, AI tools connecting to external services was a "every man for himself" nightmare—each tool needed to develop different adapters for different platforms, resulting in extremely high maintenance costs. MCP adds a middle layer between AI tools and external resources, unifying communication standards.
Claude Code is an MCP client. Install different MCP Servers, and it gains different capabilities. Just like your computer can do different things by plugging in different USB devices.
The MCP Architecture
┌─────────────────┐ MCP Protocol ┌──────────────────┐
│ Claude Code │ ◄─────────────────► │ MCP Server │
│ (MCP Client) │ │ (External Tool) │
└─────────────────┘ └──────────────────┘
│ │
│ │
▼ ▼
User Requests GitHub / Database /
Documentation /
Other ServicesThis architecture enables:
- Standardization: One protocol for all integrations
- Modularity: Add/remove capabilities without code changes
- Security: Controlled access with explicit permissions
- Extensibility: Community can build new servers independently
Three MCP Connection Methods
Before configuration, understand MCP connection methods—this affects your installation commands:
1. HTTP (Remote MCP Servers)
Characteristics: Cloud-based MCP servers, cross-network communication.
Typical Examples: GitHub, Notion, Sentry, Context7
Configuration: Usually requires only the server name and corresponding URL address.
Use Cases:
- Accessing cloud-based services
- Connecting to SaaS platforms
- Remote API integrations
2. Stdio (Local Scripts)
Characteristics: Local scripts requiring direct system access.
Typical Examples: Local Python scripts, database connectors, file system operations
Configuration: Requires specifying the command to execute the local server.
Use Cases:
- Local database connections
- File system access
- Local development tools
- Custom scripts
3. WebSocket (Bidirectional Communication)
Characteristics: Persistent bidirectional communication channels.
Typical Examples: Real-time monitoring, live data streams
Use Cases:
- Real-time application monitoring
- Live data feeds
- Interactive debugging sessions
Note: This guide focuses primarily on HTTP and Stdio connections, which cover most common use cases.
Backend Practice 1: Connecting GitHub MCP—"Thousand-Mile Vision" for Code Management
This is the most practical configuration that most intuitively demonstrates MCP's power.
GitHub officially provides an MCP Server, enabling 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 within Claude Code without switching to a browser.
Configuration Steps
claude mcp add --transport http github https://api.githubcopilot.com/mcp/Then, in your Claude Code session, enter /mcp and complete GitHub OAuth authentication following the prompts.
After Authentication: What You Can Do
Once authenticated, you can issue commands like:
Query Issues:
"Help me check the 3 most recent open issues in the repo"Create Pull Requests:
"Create a PR with title 'fix: Repair order status update bug',
include my current modification content in the description"Review Code:
"Review PR #42"Search Code:
"Find all usages of the deprecated method in the codebase"Check CI Status:
"What's the CI status for the main branch?"Permission Control: Read-Write vs. Read-Only
Important note: GitHub MCP supports OAuth 2.0 authentication, allowing users to precisely control Claude Code's access permissions to repositories:
- Read-Only: Query operations only (Issues, PRs, code search)
- Read-Write: Can create PRs, push code, modify settings
Permissions depend entirely on the scope you select during OAuth authorization.
Recommendation: For daily use, maintain read-only mode. Temporarily grant write permissions only when needed.
Security Best Practices
# For most users: Read-only access
# During OAuth, select only: repo (read), public_repo
# For trusted environments: Read-write access
# Additional scopes: repo (full), workflow
# Always review granted permissions periodically
# Visit: https://github.com/settings/applicationsBackend Practice 2: Connecting MySQL MCP—"Direct Dialogue" with Databases
This is the scenario where backend developers most intuitively feel the "efficiency leap." Previously, querying a database required manually opening a client, writing SQL, copying results, and pasting to Claude—now it's just 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 inspect database schemas 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⚠️ Critical Security Warning
Environment variable permission switches like ALLOW_INSERT_OPERATION should be set to false in production environments, maintaining read-only mode.
Only enable write operations temporarily when needed (e.g., debugging in a safe test database).
Production Database Rules:
- Never use production credentials in MCP configuration
- Create dedicated read-only database users for AI access
- Use environment variables, never hardcode passwords
- Implement connection pooling limits
- Enable query logging for audit trails
Usage Examples
Query Statistics:
You: What's the total order count in the orders table for the past week?
Claude: [Executing SQL] A total of 1,284 orders were created in the past week.Inspect Schema:
You: Help me check the structure of the product table
Claude: [Querying table structure] The product table has fields: id, name,
price, stock, etc. The price field is DECIMAL(10,2) type.Find Specific Records:
You: Which customers have order amounts exceeding 1000?
Claude: [Executing SQL] There are 47 customers, list as follows: ...Complex Queries:
You: Show me the top 10 products by revenue this month
Claude: [Executing complex JOIN query] Here are the top 10 products...Advanced: Custom SQL Queries
For complex scenarios, you can guide Claude to write specific queries:
You: I need to find users who registered but never placed an order
Claude: [Writing and executing LEFT JOIN query] Found 234 users who
registered but never placed orders. Here's the query I used...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 stops at its 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 the latest MyBatis-Plus batch insert method, and it gives you 2022's old usage—compilation errors directly.
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 actively fetches 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/mcpOptional: With API Key (For Heavy Usage)
claude mcp add --transport http context7 https://mcp.context7.com/mcp \
--header "CONTEXT7_API_KEY: YOUR_API_KEY"What You Can Do After Configuration
Query Latest APIs:
You: How to configure JWT authentication in Spring Security 6?
Claude: [Fetching via Context7] Spring Security 6 recommends the following
configuration... [provides current documentation, not 5.x outdated code]Version-Specific Queries:
You: What's the best practice for batch inserts in MyBatis-Plus 3.5.3?
Claude: [Querying by version number] MyBatis-Plus 3.5.3 recommends...Complete Code Examples:
You: Show me how to use @Async with custom thread pools
Claude: [Retrieving official examples] Not only tells you how to use it,
but also provides officially recommended implementations...Usage Examples
Framework Configuration:
You: How to configure thread pools with @Async and @EnableAsync in Spring Boot 3.2?
Claude: [Querying via Context7] Spring Boot 3.2 recommends using
ThreadPoolTaskExecutor with @Async. Configuration as follows:
@Bean
public Executor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setMaxPoolSize(10);
executor.setQueueCapacity(100);
executor.setThreadNamePrefix("async-");
executor.initialize();
return executor;
}Library Version Questions:
You: How to use Lombok 1.18.30's @Builder in inheritance scenarios?
Claude: [Querying via Context7] Recommends using @SuperBuilder...
[provides version-specific guidance with code examples]Why Context7 Matters
Without Context7:
- AI relies on training data (potentially years old)
- May suggest deprecated APIs
- Cannot access latest security patches
- Version mismatches cause confusion
With Context7:
- Real-time documentation access
- Version-specific accuracy
- Official code examples
- Reduced compilation errors
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 for Java backend development, 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 manage 5 packages and 5 configuration files.
Installation Command
npm install -g mcp-java-backend-suiteGenerate 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:
You: Help me analyze this thread dump file, check for deadlocks
Claude: [Calling JVM Diagnostics tool] Automatically analyzing...
Found 2 potential deadlocks involving threads: worker-1 and worker-3Check Database Slow Queries:
You: Help me analyze MySQL slow query logs, find SQL needing optimization
Claude: [Using DB Analyzer] Located 5 slow queries. The worst offender...Review Database Migrations:
You: Check if this Flyway migration script has risks
Claude: [Using Migration Advisor] Analyzing lock conflicts and data
loss risks... Found potential issue in V2.3__update_users.sqlIndividual Component Installation
If you don't want the full suite, install individual components:
# Install only Spring Boot Actuator
claude mcp add mcp-spring-boot-actuator -- npx -y mcp-spring-boot-actuator
# Install only DB Analyzer
claude mcp add mcp-db-analyzer -- npx -y mcp-db-analyzerJDBC MCP Server (Universal Database Interface)
This is an official JDBC-standard MCP server supporting PostgreSQL, MySQL, MariaDB, SQLite, Oracle, and almost all relational databases. It enables LLMs to inspect, query, and even modify database content—just provide a JDBC URL.
Start with JBang (One Line)
jbang jdbc@quarkiverse/quarkus-mcp-servers jdbc:mysql://localhost:3306/yourdbWhy Recommend It?
Compared to benborla/mcp-server-mysql (MySQL-focused), JDBC MCP Server has broader coverage:
- One Configuration: Covers all JDBC-compatible databases
- Complex Projects: Ideal for projects connecting multiple database types
- Sample Databases: Supports JBang direct URL download of sample databases (Chinook, Northwind) for quick experimentation
- Official Support: Maintained by Quarkus team with regular updates
Multi-Database Configuration Example
# PostgreSQL
claude mcp add postgres -- npx -y @quarkiverse/mcp-server-jdbc \
-e JDBC_URL=jdbc:postgresql://localhost:5432/mydb \
-e JDBC_USER=myuser \
-e JDBC_PASSWORD=mypassword
# SQLite
claude mcp add sqlite -- npx -y @quarkiverse/mcp-server-jdbc \
-e JDBC_URL=jdbc:sqlite:/path/to/database.dbQuick Summary: Java Backend MCP Configuration Checklist
| MCP Service | One-Sentence Explanation | Priority |
|---|---|---|
| GitHub MCP | Directly operate Issues, PRs, CI | Essential |
| MySQL MCP | Natural language database queries | Essential |
| Context7 MCP | Real-time documentation prevents obsolescence | Essential |
| Java Backend Suite | 35 tools "complete package" | Highly 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 significantly consume context window
- Start with GitHub + Context7 (cover highest-frequency needs)
- Add based on your actual workflow
Progressive Installation Strategy:
Week 1: GitHub MCP + Context7 MCP
Week 2: Add MySQL MCP (if working with databases)
Week 3: Add Java Backend Suite (if doing Java development)
Week 4+: Add specialized tools based on specific needsMonitor Context Usage:
# Check current MCP configurations
claude mcp list
# Remove unused MCPs
claude mcp remove <server-name>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 servers (GitHub, Anthropic)
- Open-source with active maintenance
- Community-vetted popular servers
Avoid:
- Unknown sources
- Unmaintained projects
- Servers requesting excessive permissions
Verification Checklist:
- [ ] Check GitHub repository activity
- [ ] Review open issues and response times
- [ ] Examine permission requirements
- [ ] Read community reviews and discussions
Red Line 2: Understand Each MCP Server's Data Access Scope
Before Authorization, Ask:
- What data can this server access?
- Does it need this level of access?
- Can permissions be more restricted?
Examples:
- GitHub Server: Can see your repositories
- Database Server: Can read table data
- File System Server: Can access specified directories
Best Practice: Apply principle of least privilege. Grant minimum necessary permissions.
Red Line 3: Production Databases Get Read-Only Access
If connecting MCP to production databases:
- Use Read-Only Accounts: Never use admin/root credentials
- Separate Environments: Different credentials for dev/staging/production
- Audit Logging: Enable query logging for all AI-accessed databases
- Rate Limiting: Prevent runaway queries from consuming resources
- Query Validation: Implement query allowlists where possible
Never:
- ❌ Give write permissions to AI-accessible production databases
- ❌ Use shared credentials across environments
- ❌ Skip audit logging for compliance reasons
Remember: One incorrect DELETE statement is enough to ruin your day.
Red Line 4: Use --scope to Control MCP Activation Range
Project-Level (Recommended for Project-Specific):
# Only available in current project
claude mcp add github --scope local ...User-Level (For Universal Tools):
# Available in all projects
claude mcp add github --scope user ...Guidelines:
- Project-specific MCPs (e.g., specific project's database): Use
--scope local - Universal MCPs (e.g., Context7 documentation queries): Use
--scope user
Don't:
- ❌ Blindly install everything globally
- ❌ Mix project-specific and universal configurations
- ❌ Forget to review scoped installations periodically
Security Summary
One Sentence: Trust must be tiered, permissions must be constrained, think thrice before write operations.
Security Checklist:
- [ ] Only install from trusted sources
- [ ] Review permissions before authorization
- [ ] Use read-only for production databases
- [ ] Apply appropriate scope (local vs. user)
- [ ] Regularly audit installed MCPs
- [ ] Enable logging for sensitive operations
- [ ] Keep MCP servers updated
Conclusion and Next Steps
The Core Philosophy
MCP's core idea is simple: Don't let AI work only from memory—connect it to the external world.
Start from Your Pain Points
You don't need to install all MCPs at once. Start from your most painful areas:
| Pain Point | Solution |
|---|---|
| Frequently checking GitHub? | → Install GitHub MCP |
| Frequently querying databases? | → Install MySQL MCP + DB Analyzer |
| Claude always uses outdated APIs? | → Install Context7 MCP |
| Frequently troubleshooting JVM issues? | → Install JVM Diagnostics or Arthas MCP |
| Frequently doing database migrations? | → Install Migration Advisor |
| Need real-time app monitoring? | → Install Spring Boot Actuator |
| Working with multiple databases? | → Install JDBC MCP Server |
The Compound Effect
Each additional MCP gives your Claude Code one more "superpower." And all of this requires just one line: claude mcp add.
Progressive Enhancement:
Base Claude Code: Code generation and file operations
+ GitHub MCP: Repository awareness and PR management
+ Context7 MCP: Up-to-date API knowledge
+ Database MCP: Direct data access and analysis
+ Monitoring MCP: Real-time application insights
= Fully integrated development platformLooking Ahead
This article covered MCP fundamentals and essential configurations. Future articles in this series will explore:
- Advanced MCP server development (build your own)
- MCP security deep-dive and audit strategies
- Performance optimization for multi-MCP environments
- Enterprise MCP deployment patterns
- Custom MCP integrations for proprietary tools
Call to Action
If this article made you realize Claude Code's potential extends far beyond "writing code," please share it with your team and community. MCP is an underestimated capability that can transform how development teams work.
Remember: The goal isn't to install every MCP available—it's to thoughtfully equip your AI assistant with the specific capabilities that amplify your unique workflow.
Start with one. Master it. Then add another. Before you know it, you'll have built a personalized AI development platform that would have seemed like science fiction just a few years ago.
This comprehensive MCP guide was originally published on 2026-04-11 as Part 6 of the Claude Code Mastery Guide series, providing practical configuration instructions and security best practices for extending Claude Code capabilities through the Model Context Protocol.