Skip to main content

MCP Server Guide

Connect AI assistants to external tools and data sources

One-sentence explanation

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.

Why it matters

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

ScenarioRequired MCP ServerEffect
Code ReviewGitHub MCPAI directly reads PRs, provides review comments
Database QueryPostgreSQL MCPAI generates and executes SQL, returns results
Log AnalysisFilesystem MCPAI reads log files, diagnoses issues
Deployment CheckAWS MCPAI checks EC2 status, optimizes configuration
Task ManagementJira MCPAI 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)
Protocol version compatibility

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

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"]
}
}
}
Security note

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

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);

Usage configuration:

{
"custom-api": {
"command": "node",
"args": ["custom-api-server.js"]
}
}

Ready to build your own MCP server?

Our hands-on project course will take you from zero to complete MCP integration.

👉 View hands-on projects →


Security Best Practices

Security first

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"
}
}

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
Performance optimization

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
Privacy protection

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:

  1. Check config file: Ensure JSON format correct, paths valid
  2. Verify environment variables: echo $GITHUB_TOKEN check if set
  3. View logs: AI tools usually have MCP connection logs
  4. 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
Debug mode

Most MCP servers support --debug or --verbose flags for detailed debug output.

Q: What's the difference between MCP and API?

Core differences:

FeatureMCPTraditional API
Design PurposeAI assistant integrationGeneral data exchange
Invocation MethodNatural language (@github)HTTP requests
Context AwareYes (understands intent)No (needs explicit params)
Learning CurveLow (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

Recommended learning path

You just read: MCP Server Integration Guide ✅

Next steps:

  1. ⏭️ Cursor Rules Configuration - Make AI follow your coding standards
  2. 🤖 AI Agents Usage Guide - Specialized AI assistant configuration
  3. 🚀 Start complete course - Systematically learn AI coding workflow

Related in-depth reading:


Last updated: 2025-11-02

Related resources: