MCP Server Guide
Connect AI assistants to external tools and data sources
MCP (Model Context Protocol) is an open protocol that lets AI assistants access external tools, databases, and APIs.
Model Context Protocol (MCP) is an open protocol that enables AI assistants to connect to external tools, databases, and APIs.
MCP allows your AI assistant to operate file systems, databases, APIs, and other real tools - like giving a brain eyes, ears, and hands. No longer just "chatting", but actually "doing things".
What is MCP?β
Explained Simplyβ
AI Assistant itself = A smart brain
MCP Server = Connecting the brain to eyes, ears, hands
Without MCP vs With MCPβ
β Without MCP:
User: Help me check the latest GitHub Issues
AI: I cannot directly access GitHub, please manually copy content for me
β With MCP (GitHub Server):
User: Help me check latest Issues
AI: [Automatically connects to GitHub API]
Issue #42: Bug in login form (2 hours ago)
Issue #43: Feature request for dark mode (4 hours ago)
[AI can directly analyze and provide suggestions]
What Can MCP Do?β
Core Capabilitiesβ
π Access File System: Read/write local files
ποΈ Connect Databases: Query PostgreSQL, MongoDB, Redis
π Call APIs: GitHub, GitLab, Jira, Slack
βοΈ Cloud Service Integration: AWS, Azure, Google Cloud
π§ Execute Commands: Run tests, build projects, deploy code
π Data Analysis: Read CSV, process JSON, generate reports
Real Application Scenariosβ
| Scenario | Required MCP Server | Effect |
|---|---|---|
| Code Review | GitHub MCP | AI directly reads PRs, provides review comments |
| Database Query | PostgreSQL MCP | AI generates and executes SQL, returns results |
| Log Analysis | Filesystem MCP | AI reads log files, diagnoses issues |
| Deployment Check | AWS MCP | AI checks EC2 status, optimizes configuration |
| Task Management | Jira MCP | AI creates Issues, updates status |
Quick Startβ
Step 1: Check if Your AI Tool Supports MCPβ
Tools supporting MCP:
- β Claude Code (Anthropic official)
- β Cursor (v0.42+)
- β Cline (VS Code extension)
- β Continue (open-source AI assistant)
MCP is currently in rapid iteration. Ensure your AI tool and MCP server versions are compatible. Using official servers is recommended for best compatibility.
Step 2: Install MCP Serverβ
- Node.js/TypeScript
- Python
Using official MCP CLI (Recommended):
# Install MCP CLI
npm install -g @modelcontextprotocol/cli
# Install GitHub MCP Server
npx @modelcontextprotocol/create-server github
# Configure
npx mcp-server-github configure
Manual Configuration (Cursor example):
Create config file ~/.cursor/mcp_servers.json:
{
"servers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/your/project"]
}
}
}
Install Python MCP SDK:
# Install MCP Python SDK
pip install mcp
# Create custom MCP server
mcp init my-server
Configuration example:
{
"servers": {
"python-server": {
"command": "python",
"args": ["-m", "mcp_server", "--config", "config.json"],
"env": {
"API_KEY": "${API_KEY}"
}
}
}
}
Basic Python MCP Server:
from mcp.server import Server
from mcp.types import Tool, TextContent
app = Server("my-python-server")
@app.call_tool()
async def get_data(arguments: dict) -> list[TextContent]:
# Implement your tool logic
result = {"status": "success", "data": arguments}
return [TextContent(type="text", text=str(result))]
if __name__ == "__main__":
app.run()
MCP servers have system-level access (files, databases, APIs). Only install servers from trusted sources and carefully review their permission configurations.
Step 3: Test MCP Connectionβ
Test prompt:
@github List the latest 5 Issues from my-repo repository
Success output:
Connected to GitHub MCP Server
Repository: username/my-repo
Recent Issues:
1. #42 - Login form bug [open] (2 hours ago)
2. #43 - Dark mode feature request [open] (4 hours ago)
3. #41 - Performance optimization suggestion [closed] (1 day ago)
...
Common MCP Serversβ
1. GitHub MCPβ
Features:
- View Issues, PRs, Commits
- Create/update Issues
- Read code files
- Query CI/CD status
Installation:
npm install -g @modelcontextprotocol/server-github
Configuration:
{
"github": {
"command": "mcp-server-github",
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
}
}
Usage examples:
@github Analyze change patterns in last 10 commits
@github Provide fix suggestions for Issue #42
@github Review code changes in PR #15
2. PostgreSQL MCPβ
Features:
- Execute SQL queries
- Analyze database performance
- Generate query optimization suggestions
- Create database schemas
Installation:
npm install -g @modelcontextprotocol/server-postgres
Configuration:
{
"postgres": {
"command": "mcp-server-postgres",
"env": {
"DATABASE_URL": "${DATABASE_URL}"
}
}
}
Usage examples:
@postgres Query number of users registered in past 7 days
@postgres Analyze index usage on users table
@postgres Generate SQL for user activity report
3. Filesystem MCPβ
Features:
- Read/write local files
- Search file contents
- Batch process files
- Analyze project structure
Configuration:
{
"filesystem": {
"command": "mcp-server-filesystem",
"args": ["/path/to/project"]
}
}
Usage examples:
@filesystem Analyze code complexity of all .ts files in src/
@filesystem Find all files containing TODO comments
@filesystem Count project lines of code (by language)
4. AWS MCPβ
Features:
- View EC2 instance status
- Manage S3 buckets
- Query CloudWatch logs
- Check Lambda functions
Configuration:
{
"aws": {
"command": "mcp-server-aws",
"env": {
"AWS_ACCESS_KEY_ID": "${AWS_ACCESS_KEY_ID}",
"AWS_SECRET_ACCESS_KEY": "${AWS_SECRET_ACCESS_KEY}",
"AWS_REGION": "us-east-1"
}
}
}
Usage examples:
@aws List all running EC2 instances
@aws View Lambda error logs from past hour
@aws Analyze S3 storage cost optimization suggestions
5. Jira MCPβ
Features:
- Create/update Issues
- Query Sprint progress
- Generate time reports
- Analyze team efficiency
Configuration:
{
"jira": {
"command": "mcp-server-jira",
"env": {
"JIRA_URL": "${JIRA_URL}",
"JIRA_EMAIL": "${JIRA_EMAIL}",
"JIRA_TOKEN": "${JIRA_TOKEN}"
}
}
}
Usage examples:
@jira Create a Bug: Login page loads slowly
@jira View all incomplete tasks in current Sprint
@jira Generate team time report for this week
Advanced Usageβ
Tip 1: Combine Multiple MCP Serversβ
Scenario: Complete development workflow
Step 1: @jira Check today's tasks
Step 2: @github Create feature branch
Step 3: @filesystem Analyze files needing modification
Step 4: [AI generates code]
Step 5: @github Create Pull Request
Step 6: @jira Update task status to "Code Review"
Tip 2: Create Automated Workflowsβ
Example: Automated code review process
# Prompt template
Please execute complete code review workflow:
1. @github Get file changes from PR #[number]
2. @filesystem Read complete content of related files
3. Analyze code quality (performance, security, best practices)
4. @github Add review comments to PR
5. Generate review summary report
Tip 3: Data Analysis Pipelineβ
Scenario: Analyze production database performance
1. @postgres Query slow query logs (past 24 hours)
2. Analyze query patterns, find performance bottlenecks
3. Generate optimization suggestions (indexes, query rewrites)
4. @filesystem Save report to reports/db-optimization.md
5. @jira Create optimization task, attach report link
Custom MCP Serversβ
Why Customize?β
Scenarios:
- Company internal APIs (CRM, ERP systems)
- Self-hosted databases or tools
- Special workflows
Creating Simple MCP Serverβ
- TypeScript
- Python
Example: Internal API MCP Server
// custom-api-server.ts
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const server = new Server({
name: 'custom-api-server',
version: '1.0.0',
}, {
capabilities: {
tools: {},
},
});
// Define tool: get user information
server.setRequestHandler('tools/call', async (request) => {
if (request.params.name === 'get_user') {
const userId = request.params.arguments?.userId;
// Call your internal API
const response = await fetch(`https://api.internal.com/users/${userId}`);
const data = await response.json();
return {
content: [{
type: 'text',
text: JSON.stringify(data, null, 2),
}],
};
}
});
// Start server
const transport = new StdioServerTransport();
await server.connect(transport);
Example: Data Processing MCP Server
from mcp.server import Server
from mcp.types import Tool, TextContent
import pandas as pd
app = Server("data-analyzer")
@app.list_tools()
async def list_tools() -> list[Tool]:
return [
Tool(
name="analyze_csv",
description="Analyze CSV file and return statistics",
inputSchema={
"type": "object",
"properties": {
"file_path": {"type": "string"}
},
"required": ["file_path"]
}
)
]
@app.call_tool()
async def call_tool(name: str, arguments: dict) -> list[TextContent]:
if name == "analyze_csv":
df = pd.read_csv(arguments["file_path"])
stats = df.describe().to_string()
return [TextContent(type="text", text=stats)]
if __name__ == "__main__":
app.run()
Usage configuration:
{
"custom-api": {
"command": "node",
"args": ["custom-api-server.js"]
}
}
Our hands-on project course will take you from zero to complete MCP integration.
Security Best Practicesβ
MCP servers can access sensitive data and system resources. Must follow security best practices to protect your system and data.
1. API Token Managementβ
β Insecure:
{
"github": {
"env": {
"GITHUB_TOKEN": "ghp_abc123def456" // Hardcoded
}
}
}
β Secure:
{
"github": {
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}" // Environment variable
}
}
}
# .env file (ensure added to .gitignore)
GITHUB_TOKEN=ghp_your_token_here
2. Minimize Permissionsβ
Grant only necessary permissions:
- GitHub Token: Read-only (unless write needed)
- Database: Read-only user (analysis scenarios)
- AWS: Limit specific services and operations
3. Audit Logsβ
Record MCP operations:
{
"logging": {
"level": "info",
"file": "~/.mcp/logs/operations.log"
}
}
Recommended MCP Resourcesβ
Official Resourcesβ
Community Resourcesβ
- Vibe Coding Tools - MCP Collection
- 100+ MCP server configurations
- GitHub, GitLab, Jira connections
- AWS, Azure, GCP integrations
- Browse MCP library β
FAQβ
Q: Does MCP affect AI response speed?
Answer:
- Slight impact (typically +0.5-2 seconds)
- Depends on external API response speed
- Filesystem MCP has almost no impact
If response is slow, check if external services (APIs, databases) are slow. Can optimize using caching or limiting query scope.
Q: Is MCP data sent to AI servers?
Answer:
- MCP executes locally first
- Only results sent to AI (not raw credentials)
- Sensitive data can be filtered locally
Example flow:
1. AI request: @github Get Issue
2. Local MCP server: Calls GitHub API
3. Returns result: Issue data (no Token)
4. AI analysis: Generate suggestions based on returned data
You can implement filtering logic in MCP server to ensure sensitive information (passwords, keys, personal info) is not sent to AI.
Q: How many MCP servers can one AI assistant use?
Answer:
- Technically unlimited
- Practically: 5-10 most commonly used
- Too many increases configuration complexity
Recommendation:
Core MCP (must install):
- Filesystem (local files)
- GitHub (code repository)
On-demand MCP:
- PostgreSQL (if using SQL)
- AWS (if using cloud services)
- Jira (if using task management)
Q: How to debug MCP server connection issues?
Troubleshooting steps:
- Check config file: Ensure JSON format correct, paths valid
- Verify environment variables:
echo $GITHUB_TOKENcheck if set - View logs: AI tools usually have MCP connection logs
- Manual test: Directly run MCP server command to test
Common errors:
# Error 1: Command not found
# Solution: Check if npx or node installed
# Error 2: Insufficient permissions
# Solution: Check Token permission scope
# Error 3: Environment variable not set
# Solution: source .env or restart terminal
Most MCP servers support --debug or --verbose flags for detailed debug output.
Q: What's the difference between MCP and API?
Core differences:
| Feature | MCP | Traditional API |
|---|---|---|
| Design Purpose | AI assistant integration | General data exchange |
| Invocation Method | Natural language (@github) | HTTP requests |
| Context Aware | Yes (understands intent) | No (needs explicit params) |
| Learning Curve | Low (natural interaction) | High (need to learn API) |
Example:
MCP method:
User: @github Help me find most active contributors in this project
AI: [Understands intent] β [Calls multiple GitHub APIs] β [Analyzes data] β [Returns result]
API method:
1. Check docs for /repos/{owner}/{repo}/contributors
2. Write code to call API
3. Parse JSON response
4. Manually sort and analyze
You just read: MCP Server Integration Guide β
Next steps:
- βοΈ Cursor Rules Configuration - Make AI follow your coding standards
- π€ AI Agents Usage Guide - Specialized AI assistant configuration
- π Start complete course - Systematically learn AI coding workflow
Related in-depth reading:
- AI Coding Roadmap - Complete learning path
- AI Tools Comparison - Understand MCP support
- Hands-on Projects - MCP applications in projects
Last updated: 2025-11-02
Related resources:
- Cursor Rules - Project standard configuration
- AI Agents - Specialized assistants
- MCP Official Documentation