Skip to the content.

Model Context Protocol (MCP)

Information

Introduction

The Model Context Protocol (MCP) is an open standard that enables developers to build secure, two-way connections between their data sources and AI models. It provides a universal way for AI models (like Claude, ChatGPT, or Gemini) to access local and remote data, tools, and prompts without needing custom integrations for every single data source.

What is it for?

MCP solves the problem of “context fragmentation” by allowing AI assistants to:

Key Components

Development Tools & SDKs

To build your own MCP servers or clients, you can use the following SDKs and libraries:

Python

Java / Kotlin

Node.js / TypeScript

Building an MCP Server

Building an MCP server involves defining tools, resources, and prompts that an AI host can use.

Python (FastMCP)

FastMCP is a high-level framework that makes it easy to build MCP servers with Python.

1. Installation:

pip install fastmcp

2. Create a server (server.py):

from fastmcp import FastMCP

# Create an MCP server
mcp = FastMCP("My Server")


# Add a tool
@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b


# Add a resource
@mcp.resource("echo://{message}")
def echo_resource(message: str) -> str:
    """Echo a message as a resource"""
    return f"Resource content: {message}"


if __name__ == "__main__":
    mcp.run()

3. Running:

python server.py

TypeScript (Official SDK)

1. Installation:

npm install @modelcontextprotocol/sdk

2. Create a server (index.ts):

import {Server} from "@modelcontextprotocol/sdk/server/index.js";
import {StdioServerTransport} from "@modelcontextprotocol/sdk/server/stdio.js";
import {
    CallToolRequestSchema,
    ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";

const server = new Server(
    {
        name: "my-server",
        version: "1.0.0",
    },
    {
        capabilities: {
            tools: {},
        },
    }
);

server.setRequestHandler(ListToolsRequestSchema, async () => {
    return {
        tools: [
            {
                name: "calculate_sum",
                description: "Add two numbers together",
                inputSchema: {
                    type: "object",
                    properties: {
                        a: {type: "number"},
                        b: {type: "number"},
                    },
                    required: ["a", "b"],
                },
            },
        ],
    };
});

server.setRequestHandler(CallToolRequestSchema, async (request) => {
    if (request.params.name === "calculate_sum") {
        const {a, b} = request.params.arguments as { a: number; b: number };
        return {
            content: [{type: "text", text: String(a + b)}],
        };
    }
    throw new Error("Tool not found");
});

const transport = new StdioServerTransport();
await server.connect(transport);

Installation

General

To use MCP, you typically need an MCP Host (the AI assistant) and one or more MCP Servers.

Local Server Setup (Node.js/Python)

Most MCP servers are written in Node.js or Python. You can install them globally or run them directly using tools like npx (Node.js) or uvx (Python).

# Example: Installing an MCP server via npm
npm install -g @modelcontextprotocol/server-github

# Example: Running an MCP server with uv (Python)
uvx mcp-server-sqlite --db-path ./my-database.db

Configuration

To start using MCP servers, you need to configure your AI host to recognize and connect to them.

Claude Desktop Configuration

Claude Desktop is one of the primary hosts for MCP.

  1. Locate Configuration File:
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  2. Edit Configuration: Add your MCP servers to the mcpServers object.

Example configuration:

{
    "mcpServers": {
        "sqlite": {
            "command": "uvx",
            "args": [
                "mcp-server-sqlite",
                "--db-path",
                "C:/path/to/your/db.sqlite"
            ]
        },
        "github": {
            "command": "npx",
            "args": [
                "-y",
                "@modelcontextprotocol/server-github"
            ],
            "env": {
                "GITHUB_PERSONAL_ACCESS_TOKEN": "your_token_here"
            }
        }
    }
}
  1. Restart Claude: Close and reopen the Claude Desktop application for changes to take effect.

Junie (JetBrains AI Assistant) Configuration

Junie (the JetBrains AI Assistant) can also act as an MCP host, allowing it to interact with your local tools and data directly within your IDE.

  1. Open Settings: Go to Settings (Windows/Linux) or Settings (macOS) in your JetBrains IDE (IntelliJ IDEA, WebStorm, PyCharm, etc.).
  2. Navigate to AI Assistant: Select AI Assistant in the sidebar.
  3. MCP Settings: Look for the Model Context Protocol (MCP) or Tools section.
  4. Add Server:
    • Click the + (Add) button.
    • Choose a Name for your server (e.g., “Postgres”).
    • Specify the Command (e.g., npx or uvx).
    • Add Arguments as separate items (e.g., -y, @modelcontextprotocol/server-postgres).
    • Set Environment Variables if required by the server (e.g., database connection strings or API keys).
  5. Apply and Save: Click OK or Apply.

How to start using it

Once configured, the AI assistant will automatically detect the available tools from the MCP server.

With Claude Desktop

With Junie (JetBrains AI)

Usage, tips and tricks

Coding tips and tricks

Community & Ecosystem

See also