Independent · Source-cited · No sponsored rankingsSources linked in every article
AIToolRanked
AI Coding · 10 min read

MCP Protocol Tutorial 2026: Build and Connect MCP Servers

A practical introduction to the Model Context Protocol (MCP): how servers, clients and transports work, how to connect common AI tools, and how to build a custom server with the official Python and TypeScript SDKs.

RA
· · Founder, AIToolRanked
MCP Protocol Tutorial 2026: Build and Connect MCP Servers
On this page

The Model Context Protocol (MCP) is an open standard for connecting AI applications to data sources and tools. MCP reduces custom integrations by providing a standardized client-server architecture. AI applications including Cursor, Claude Desktop, Claude Code, and JetBrains IDEs support MCP as of September 2026.

What is the Model Context Protocol and why does it matter in 2026?

The Model Context Protocol is an open standard that enables secure, two-way connections between AI applications and data sources, reducing the need for custom integrations between every tool and service. MCP turns a multiplicative integration problem into an additive one through a standardized client-server architecture.

The MCP specification ↗ compares MCP to the Language Server Protocol: just as LSP standardized how editors add support for programming languages, MCP standardizes how AI applications access external data and capabilities. Anthropic introduced MCP as an open standard ↗ in November 2024.

The November 2025 specification revision (2025-11-25) addressed production concerns, including OpenID Connect Discovery for authorization servers, incremental scope consent, OAuth Client ID Metadata Documents for client registration, and experimental support for long-running tasks. As of September 2026, the latest specification version is 2026-07-28.

MCP operates through three components. MCP servers expose capabilities like database access, file operations, or API integrations. A database server can let AI tools query data. A GitHub server can support code review workflows.

MCP clients are the connectors inside AI applications (called hosts) that connect to servers. Popular hosts include Cursor for code editing, Claude Desktop for AI assistance, Devin Desktop (formerly Windsurf) for development workflows, and JetBrains IDEs for integrated development.

The protocol layer handles communication between clients and servers using JSON-RPC 2.0 messages. It manages initialization, capability negotiation, and request-response patterns. This standardized communication reduces custom integration code.

Before MCP, connecting 10 AI tools to 10 data sources could require up to 100 custom integrations. Each connection needed unique code, ongoing maintenance, and updates when systems changed. This multiplicative complexity made comprehensive AI tool adoption impractical.

MCP turns this into an additive problem. The same 10 tools and 10 services need only 20 implementations total: 10 servers and 10 clients. Each new tool or service adds one integration point rather than requiring connections to everything else.

Traditional integration approaches rely on proprietary APIs and custom connectors. Each AI tool vendor creates unique integration methods. Developers must learn multiple systems and maintain separate codebases. This fragmentation limits tool interoperability and increases technical debt.

MCP provides a vendor-neutral alternative that works across platforms. Tools supporting MCP can connect to any compatible MCP server. This composability lets developers choose AI tools based on capabilities rather than integration constraints.

How does MCP protocol architecture work with servers, clients, and communication patterns?

MCP architecture consists of servers that expose capabilities, clients that consume those capabilities, and a standardized protocol layer based on JSON-RPC 2.0 that handles communication between them. This design lets any MCP-compatible AI tool work with any MCP server without custom integration code.

The protocol uses JSON-RPC request, response and notification messages. Clients and servers negotiate capabilities during initialization, then clients discover and call a server's tools, resources and prompts through standardized message formats. This consistency makes MCP implementations predictable and maintainable.

The specification defines two standard transports: stdio for local servers launched as a subprocess, and Streamable HTTP for remote servers. Streamable HTTP replaced the older HTTP+SSE transport, and implementations can add custom transports. This flexibility allows MCP to work in local development and distributed cloud architectures.

MCP servers act as bridges between AI tools and existing systems. A database MCP server can let AI applications query databases and analyze data from live business systems. The server controls which queries are allowed and how results are formatted.

GitHub MCP servers integrate AI tools with code repositories. GitHub maintains an official GitHub MCP server ↗ for repository, issue and pull request workflows. AI assistants can read code, suggest improvements, and create pull requests through standardized MCP interactions.

Filesystem MCP servers provide controlled access to files. The reference filesystem server only allows access to directories you list, so AI tools can read documentation, analyze logs, and process data files within those limits. This capability supports AI-powered development workflows.

Cursor supports MCP servers through project-level .cursor/mcp.json and global ~/.cursor/mcp.json configuration files, plus a UI for installing and managing servers. Developers connect Cursor to databases and development tools through configuration changes, enabling context-aware code suggestions and automated development tasks.

Claude Desktop supports local MCP servers through a JSON configuration file. Users configure multiple MCP servers to give Claude access to files, databases, and external services, with Claude asking for approval before each tool action.

JetBrains IDEs integrate MCP support across their product line. JetBrains AI Assistant can connect to MCP servers, and starting with version 2025.2, JetBrains IDEs also include a built-in MCP server that external clients such as Claude Code can use.

The MCP protocol layer handles discovery through standardized capability announcements. When clients connect to servers, they receive information about available tools, resources, and prompts. This discovery process reduces manual configuration and setup complexity.

Authorization in MCP is optional and applies to HTTP-based transports. When used, it is based on OAuth 2.1, with MCP servers acting as OAuth resource servers. Servers using the stdio transport should instead retrieve credentials, such as API keys, from the environment. Optional authorization extensions are maintained separately.

Capability negotiation allows clients and servers to agree on supported features during initialization. Servers declare which features they offer, such as tools, resources or prompts, and OAuth scopes can limit what an authorized client may do. This granular control supports secure multi-tenant deployments.

How do you implement MCP step-by-step for beginners?

Getting started with MCP requires selecting an initial server, configuring your AI client, testing the connection, and gradually expanding capabilities based on your specific use cases. This four-step approach minimizes complexity while building practical experience with the protocol.

Many developers start with the filesystem server because it provides immediate benefits without external dependencies. Once you understand basic patterns, adding database or API integrations becomes straightforward.

System requirements depend on your implementation language. The official Python SDK requires Python 3.10+, and the TypeScript SDK runs on Node.js, Bun and Deno (the current @modelcontextprotocol/server package requires Node.js 20+). Official SDKs also exist for C#, Go, Java, Kotlin, PHP, Ruby, Rust and Swift. Windows, macOS, and Linux are supported platforms.

Development environment setup follows consistent patterns across operating systems. macOS users install Python and Node.js through Homebrew. Ubuntu users leverage apt packages. Windows developers use official installers or Windows Subsystem for Linux.

Package managers streamline MCP installation. Python developers use pip or the uv package manager, and Python-based reference servers can be run with uvx. JavaScript developers choose npm, yarn, or pnpm, and TypeScript-based servers can be run directly with npx.

The filesystem MCP server provides controlled access to local files and directories. It demonstrates core MCP concepts without requiring external services. It is published as a Node.js package and is usually run with npx, so there is nothing to install globally.

To run it manually:
bash
npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/directory
Configuration requires specifying which directories the server can access. You pass the allowed directories as arguments, and the server refuses access to anything outside them. This security-first approach prevents unauthorized file access while enabling AI tool functionality.

Cursor configuration involves adding MCP server details to .cursor/mcp.json in your project or ~/.cursor/mcp.json in your home directory, or installing servers from Cursor's Customize page. Include the server command, arguments such as allowed directories, and any environment variables.

Claude Desktop uses a JSON configuration file, claude_desktop_config.json, which you open from Settings → Developer → Edit Config (on macOS it is in ~/Library/Application Support/Claude/). The configuration specifies the command and arguments for each server:

json
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory"]
}
}
}
JetBrains IDE configuration follows similar patterns across IDEs. Open Settings → Tools → AI Assistant → Model Context Protocol (MCP) and add server configurations.

Connection testing verifies that your AI client can communicate with MCP servers. Start with simple requests like "list files in my project directory" or "read the README file." A working connection returns file listings or file content after you approve the tool call.

How do you build custom MCP servers using Python and TypeScript?

Custom MCP servers enable integration with proprietary systems, internal APIs, and specialized data sources that don't have existing server implementations. The official SDKs provide frameworks for building servers with minimal boilerplate code.

Server development follows established patterns regardless of implementation language. You define capabilities, implement request handlers, and configure security controls. The SDKs handle protocol details, allowing focus on business logic and integration requirements.

Python MCP development uses the official mcp package (install with pip install "mcp[cli]" or uv add "mcp[cli]") for protocol handling and server infrastructure. The SDK uses decorators and type hints, so function signatures become the tool's input schema:

python
from mcp.server import MCPServer

mcp = MCPServer("my-custom-server")

@mcp.tool()
async def database_query(query: str) -> str:
"""Run a read-only query against the database."""

Your database integration logic here

result = await database.execute(query)
return f"Query result: {result}"

if name == "main":
mcp.run()
Database integration requires attention to security and performance. Use connection pooling for concurrent requests, implement query validation to prevent SQL injection, and consider read-only connections for most MCP use cases.

TypeScript MCP servers offer type safety and integration with JavaScript ecosystems. The official SDK (npm install @modelcontextprotocol/server) uses Zod schemas for tool inputs, which catch many integration errors at compile time:

typescript
import { McpServer } from '@modelcontextprotocol/server';
import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
import * as z from 'zod/v4';

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

server.registerTool(
'api_request',
{
description: 'Make HTTP requests to external APIs',
inputSchema: z.object({ url: z.string(), method: z.string() })
},
async ({ url, method }) => {
// API integration logic
const response = await fetch(url, { method });
return { content: [{ type: 'text', text: await response.text() }] };
}
);

await server.connect(new StdioServerTransport());
Tool execution in MCP servers handles dynamic operations like database queries, API calls, or file operations. Tools receive structured input parameters and return formatted results to AI clients. Input validation prevents security vulnerabilities and ensures reliable operation.

Resource provisioning supplies data and context to AI applications. Resources include documentation, configuration files, or reference data that AI tools need for decision-making. Unlike tools, resources are application-controlled context rather than actions the model executes.

Authentication strategies in custom MCP servers depend on the transport. Local stdio servers typically read API keys from environment variables, while remote HTTP servers should follow the specification's OAuth 2.1-based authorization flow. Choose authentication methods based on security requirements and existing infrastructure.

Authorization controls determine what actions authenticated clients can perform. Implement role-based access control (RBAC) or OAuth scopes for complex scenarios, or simple read/write permissions for basic use cases. Document permission requirements to help users configure appropriate access levels.

What are real-world MCP use cases and implementation scenarios?

MCP implementations solve business problems by connecting AI tools with existing systems and workflows. Focused deployments that target a specific use case are easier to secure and maintain than trying to integrate everything at once.

Common implementation patterns include data analysis workflows, development automation, customer service enhancement, and content management systems.

Database MCP servers turn AI tools into data analysis assistants. Instead of exporting data to spreadsheets or running manual queries, analysts ask AI assistants to investigate trends, identify anomalies, and generate insights directly from live databases.

PostgreSQL integration is a common MCP use case. The original reference PostgreSQL server, which offered read-only database access with schema inspection, has been archived by the MCP project, so use a maintained community or vendor server and keep connections read-only for safety. Analysts can ask questions like "What are our top 10 customers by revenue this quarter?" and review the generated query and results.

Development workflow automation connects AI tools with code repositories, CI/CD pipelines, and project management systems. Developers use MCP-enabled AI assistants to review code, generate documentation, and manage deployments through natural language commands.

Customer service enhancement integrates AI tools with CRM systems, knowledge bases, and communication platforms. Support agents use AI assistants that can access customer history, product documentation, and escalation procedures through MCP connections.

Content management workflows connect AI tools with document repositories, media libraries, and publishing systems. Content creators use AI assistants to research topics, generate drafts, and manage publication workflows through standardized MCP interfaces.

Financial analysis systems integrate AI tools with accounting software, market data feeds, and reporting platforms. Financial analysts use AI assistants to generate reports and analyze trends through MCP-enabled data access.

Sources

RA
About the author
Founder of AIToolRanked · Writing about AI tools since 2025

Checked against the sources linked in this article. First-hand testing is claimed only where it happened. Corrections: rai@aitoolranked.com.

Continue reading

All articles →
The Briefing

One email a week. Every tool worth your time.

Join builders getting source-cited AI tool analysis. Never sponsored, always attributed.

No spam · Unsubscribe anytime

Source-cited reviews and comparisons of AI tools, published by Rai Ansar.

Most read
Topics