15 min read
Beginner
Getting Started

What is Model Context Protocol?

Understand the basics of MCP and why it matters for AI development

MCPgee Team

MCP Expert

Basic understanding of APIsFamiliarity with AI/LLM conceptsBasic programming knowledge (any language)

What is Model Context Protocol?

Introduction

The Model Context Protocol (MCP) is an open protocol that standardizes how AI applications connect with external data sources and tools. Developed by Anthropic, MCP provides a universal way for AI assistants like Claude, ChatGPT, and other language models to securely access and interact with local services, databases, APIs, and development tools.

Think of MCP as a bridge between the AI world and your existing infrastructure. Just as HTTP standardized web communication, MCP standardizes AI-to-tool communication. If you are new to AI tooling, this guide will give you a solid foundation before you move on to building your first MCP server.

Why MCP Matters

The Problem It Solves

Before MCP, integrating AI assistants with external tools presented several challenges:

  1. Fragmentation: Each AI platform had its own plugin system or API format
  2. Security Concerns: Direct access to databases and systems posed risks
  3. Maintenance Overhead: Multiple integrations for different AI providers
  4. Limited Functionality: Basic text-in, text-out interactions

The MCP Solution

MCP addresses these challenges by providing:

  • Universal Protocol: One integration works across multiple AI platforms
  • Built-in Security: Controlled access with proper authentication
  • Rich Interactions: Support for structured data, streaming, and complex operations
  • Local-First Design: Keep sensitive data on your infrastructure

You can explore the growing ecosystem of production-ready servers on the MCP servers directory and find compatible MCP clients that already support the protocol.

Core Architecture

Client-Server Model

MCP follows a client-server architecture:

plaintext
┌─────────────────┐         ┌─────────────────┐
│   MCP Client    │ <-----> │   MCP Server    │
│ (AI Assistant)  │   MCP   │ (Your Service)  │
└─────────────────┘         └─────────────────┘
MCP Clients are AI applications that consume resources:
  • Claude Desktop - Anthropic's native app with built-in MCP support
  • Claude Code - CLI-based AI assistant for developers
  • VS Code with AI extensions
  • Custom AI applications
MCP Servers expose resources and tools:
  • File system servers for local file access
  • Database connectors for querying data
  • API wrappers for third-party services
  • Development tools for code analysis and testing

Browse the full catalog at the servers directory.

Communication Flow

  1. Discovery: Client discovers available servers
  2. Connection: Client establishes connection via transport
  3. Initialization: Server declares available resources/tools
  4. Interaction: Client requests resources or invokes tools
  5. Response: Server processes and returns results

Key Concepts

1. Resources

Resources represent data that AI can read:

typescript
interface Resource {
  uri: string;           // Unique identifier like 'file:///path/to/doc'
  name: string;          // Human-readable name
  description?: string;  // What this resource contains
  mimeType?: string;     // Content type (text/plain, application/json)
}

Example resources:

  • Files: file:///home/user/project/README.md
  • Database records: db://users/123
  • API responses: api://weather/current

2. Tools

Tools are functions AI can execute:

typescript
interface Tool {
  name: string;          // Unique function name
  description: string;   // What the tool does
  inputSchema: {         // JSON Schema for parameters
    type: 'object',
    properties: {...},
    required: [...]
  }
}

Example tools:

  • queryDatabase: Execute SQL queries
  • writeFile: Create or update files
  • sendEmail: Send emails via SMTP

3. Prompts

Prompts are reusable templates that servers expose to clients:

typescript
interface Prompt {
  name: string;          // Template identifier
  description: string;   // When to use this prompt
  arguments: [...]       // Required parameters
}

4. Transport Layers

MCP supports multiple transport mechanisms:

  1. stdio (Standard I/O)
- Best for local processes - Used by Claude Desktop and Claude Code - Secure by default
  1. Streamable HTTP
- The current standard for remote/network MCP servers - Supports bidirectional communication over HTTP - Works well with modern cloud infrastructure
  1. SSE (Server-Sent Events) - Deprecated
- Was previously used for remote servers - Being replaced by Streamable HTTP in new implementations - Existing SSE servers will continue to work but new projects should use Streamable HTTP
Note: Earlier documentation sometimes mentions WebSocket as a transport. WebSocket is not an official MCP transport. Use stdio for local servers and Streamable HTTP for remote deployments.

Protocol Messages

Request-Response Pattern

MCP uses JSON-RPC 2.0 for communication:

json
// Client Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "resources/list",
  "params": {}
}

// Server Response
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "resources": [
      {
        "uri": "file:///data/users.json",
        "name": "User Database",
        "mimeType": "application/json"
      }
    ]
  }
}

Common Methods

  1. Initialization
- initialize: Establish connection - initialized: Confirm setup
  1. Resource Operations
- resources/list: Get available resources - resources/read: Read resource content
  1. Tool Operations
- tools/list: Get available tools - tools/call: Execute a tool
  1. Prompt Operations
- prompts/list: Get available prompts - prompts/get: Retrieve prompt template

Real-World Use Cases

1. Database Assistant

An MCP server can wrap your database and let an AI assistant query it safely using natural language. See practical examples in our guide on building MCP servers.

typescript
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';

const server = new McpServer({
  name: 'database-assistant',
  version: '1.0.0',
});

server.tool('queryDatabase', {
  description: 'Execute read-only SQL queries',
  inputSchema: {
    query: { type: 'string', description: 'SQL SELECT query' },
    database: { type: 'string', description: 'Target database name' },
  },
}, async ({ query, database }) => {
  const results = await db.query(query);
  return { content: [{ type: 'text', text: JSON.stringify(results) }] };
});

2. Development Environment

typescript
server.tool('runTests', {
  description: 'Execute the project test suite',
  inputSchema: {
    pattern: { type: 'string', description: 'Test file pattern' },
  },
}, async ({ pattern }) => {
  const results = await testRunner.run(pattern);
  return { content: [{ type: 'text', text: results.summary }] };
});

3. Document Management

typescript
server.tool('convertDocument', {
  description: 'Convert documents between formats',
  inputSchema: {
    source: { type: 'string', description: 'Source file path' },
    targetFormat: { type: 'string', enum: ['pdf', 'docx', 'md'] },
  },
}, async ({ source, targetFormat }) => {
  const output = await converter.convert(source, targetFormat);
  return { content: [{ type: 'text', text: `Converted to ${output}` }] };
});

Benefits Over Traditional Approaches

MCP vs REST APIs

For a deep comparison, read MCP vs Traditional APIs or the blog post MCP vs REST APIs: When to Use What.

FeatureMCPREST API
StandardizationProtocol-levelApplication-level
DiscoveryBuilt-inRequires documentation
Type SafetyJSON SchemaVaries
StreamingNative supportLimited
Context AwarenessYesNo

MCP vs Direct Database Access

FeatureMCPDirect Access
SecurityControlled accessFull access
AbstractionHigh-level operationsRaw queries
Audit TrailBuilt-inManual
Multi-tenancySupportedComplex

Getting Started with MCP

For AI Users

  1. Install a Compatible Client
- Claude Desktop (built-in support) - Claude Code (CLI for developers) - VS Code with MCP extension
  1. Configure Servers
json
{
     "mcpServers": {
       "filesystem": {
         "command": "npx",
         "args": ["@modelcontextprotocol/server-filesystem", "/path/to/data"]
       }
     }
   }
  1. Start Using
- Resources appear in AI context - Tools available for invocation - Natural language interaction

For Developers

  1. Choose Implementation Language
- TypeScript/JavaScript - use McpServer from @modelcontextprotocol/sdk/server/mcp.js (high-level) or Server from @modelcontextprotocol/sdk/server/index.js (low-level) - Python - use from mcp.server.fastmcp import FastMCP - Go, Rust, C# (community SDKs available)
  1. Define Server Capabilities
- What resources to expose - Which tools to implement - Security boundaries
  1. Implement and Test
- Follow our step-by-step first server tutorial - Connect to Claude Desktop for live testing - Publish to the servers directory

Security Considerations

Access Control

  • Principle of Least Privilege: Only expose necessary resources
  • Authentication: Verify client identity
  • Authorization: Check permissions per operation
  • Audit Logging: Track all operations

Data Protection

  • Encryption: Use TLS for network transport (Streamable HTTP)
  • Sanitization: Validate all inputs
  • Rate Limiting: Prevent abuse
  • Sandboxing: Isolate server processes

Future of MCP

Ecosystem Growth

The MCP ecosystem is expanding rapidly. You can track new servers being published at the servers directory and follow ecosystem updates on the MCPGee blog.

  1. More AI Platforms: Adoption beyond Claude - ChatGPT, Gemini, and others
  2. Richer Integrations: Complex multi-step workflows
  3. Standardization: Industry-wide protocol adoption
  4. Tool Marketplace: Reusable, composable MCP servers

Advanced Features

  1. Streaming Operations: Real-time data processing via Streamable HTTP
  2. Batch Operations: Efficient bulk processing
  3. Event Subscriptions: Push-based updates
  4. Distributed Systems: Multi-server coordination

Conclusion

The Model Context Protocol represents a fundamental shift in how AI systems interact with external tools and data. By providing a standardized, secure, and flexible protocol, MCP enables developers to build powerful AI integrations while maintaining control over their infrastructure.

Whether you are looking to give AI access to your databases, automate development workflows, or build custom AI-powered applications, MCP provides the foundation for safe, scalable, and maintainable integrations.

Ready to get hands-on? Continue to the Setting Up Your First MCP Server tutorial to build a working server in under 20 minutes.

Code Examples

Basic MCP Server with McpServer (High-Level API)typescript
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';

// Create MCP server instance using the high-level API
const server = new McpServer({
  name: 'my-first-mcp-server',
  version: '1.0.0',
});

// Define a simple tool
server.tool('hello', {
  description: 'Say hello to someone',
  inputSchema: {
    name: { type: 'string', description: 'Name to greet' },
  },
}, async ({ name }) => {
  return {
    content: [
      {
        type: 'text',
        text: `Hello, ${name}! Welcome to MCP.`,
      },
    ],
  };
});

// Start the server
const transport = new StdioServerTransport();
await server.connect(transport);
MCP Client Configuration Examplejson
{
  "mcpServers": {
    "filesystem": {
      "command": "node",
      "args": ["./servers/filesystem-server.js"],
      "env": {
        "FILE_ROOT": "/home/user/documents"
      }
    },
    "database": {
      "command": "python",
      "args": ["./servers/database_server.py"],
      "env": {
        "DB_CONNECTION": "postgresql://localhost/mydb"
      }
    },
    "github": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_TOKEN": "${GITHUB_TOKEN}"
      }
    }
  }
}
Python MCP Server with FastMCPpython
from mcp.server.fastmcp import FastMCP

# Create server using FastMCP (recommended Python approach)
mcp = FastMCP("my-first-server")

@mcp.tool()
def hello(name: str) -> str:
    """Say hello to someone."""
    return f"Hello, {name}! Welcome to MCP."

@mcp.resource("config://app")
def get_config() -> str:
    """Return application configuration."""
    return "App configuration data here"

# Run with: python server.py
mcp.run()

Key Takeaways

  • MCP standardizes how AI assistants connect with external tools and data sources
  • It uses a client-server architecture with stdio for local and Streamable HTTP for remote transport
  • Resources represent readable data, while tools represent executable functions
  • Security and access control are built into the protocol design
  • MCP enables local-first AI integrations that keep sensitive data on your infrastructure

Troubleshooting

What's the difference between MCP and LangChain/OpenAI plugins?

MCP is a protocol, not a framework. While LangChain is a development framework for building LLM applications and OpenAI plugins are specific to ChatGPT, MCP is a universal protocol that works across different AI platforms. You can use MCP with LangChain or implement MCP servers that work with multiple AI providers.

Do I need to modify my existing APIs to use MCP?

No, you don't need to modify existing APIs. MCP servers act as adapters that translate between your existing systems and the MCP protocol. You can create an MCP server that wraps your current APIs, databases, or services without changing them.

Is MCP only for local development?

While MCP excels at local-first integrations via stdio transport, it is not limited to local use. MCP supports Streamable HTTP transport for remote network communication. You can deploy MCP servers to the cloud, use them in production environments, or create hybrid setups with both local and remote servers. Note that SSE transport is deprecated in favor of Streamable HTTP.

Next Steps

  • Set up your first MCP server in the next tutorial
  • Explore the official MCP SDK documentation
  • Browse production-ready servers in the servers directory
  • Review existing MCP server implementations on GitHub

Was this helpful?

Share tutorial:

Stay Updated with MCP Insights

Join 5,000+ developers and get weekly insights on MCP development, new server releases, and implementation strategies delivered to your inbox.

We respect your privacy. Unsubscribe at any time.

MCPgee Team

We write in-depth guides, tutorials, and reviews to help developers get the most out of the Model Context Protocol ecosystem.

Frequently Asked Questions

Explore MCP Servers

Browse our directory of 33,000+ MCP servers. Find the perfect tools for your AI-powered workflows.