Skip to main content

MCP Servers Explained: Connect AI Agents to Any Tool or API (2026)

· 8 min read
Yassine El Haddad
Software Developer & Automation Specialist

I build production AI agents, web scrapers, and automation pipelines. Most of what I publish here comes from the actual problems they run into: proxies that get banned, anti-bot stacks that fingerprint your client, RAG that drifts when the underlying data moves. Stack: Python, TypeScript, Go, FastAPI, LangChain, Crawlee, Playwright, deployed on AWS, GCP, and Cloudflare.

The Model Context Protocol (MCP) is an open standard (originated by Anthropic in November 2024, now open and community-governed) that lets AI assistants like Claude call external tools, read resources, and use reusable prompts. Instead of hardcoding integrations, you run MCP servers, lightweight processes that expose capabilities over a simple protocol. Claude (Desktop and Code), ChatGPT, VS Code, Cursor, and many other MCP hosts connect to these servers, so your AI can scrape the web, query databases, or run APIs on your behalf. Think of MCP as a USB-C port for AI: one standard plug instead of a custom cable per integration. Explore the Apify MCP server.

What MCP Is

MCP defines how AI applications (the host) communicate with external services (the server). The host sends requests; the server executes tools, returns resources, or invokes prompts. The protocol is transport-agnostic: stdio for local processes, and remote Streamable HTTP (which replaced the older HTTP+SSE transport) for hosted services. Any client that supports MCP can use any MCP server.

This decoupling is the main advantage over traditional function calling: you don't ship tool definitions in each application. You run one MCP server, and every compatible host (Claude Desktop, Cursor, your own app) can use it.

Architecture: Host ↔ Server ↔ Resources

┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ MCP Host │ JSON │ MCP Server │ │ External APIs │
│ (Claude, │ ←───→ │ (your tool │ ──────→ │ Apify, DB, │
│ Cursor) │ RPC │ or service) │ │ etc. │
└─────────────────┘ └─────────────────┘ └─────────────────┘

The host connects to the server over stdio or HTTP. When you ask Claude to "scrape this URL," the host calls the server's run_actor tool (or equivalent). The server runs the Apify Actor, fetches results, and returns them. The host injects that context back into the conversation.

Three MCP Primitives

PrimitivePurposeExample
ToolsFunction calls the AI can invokerun_actor, get_weather, search_postgres
ResourcesRead-only context (URIs, content)file:///path/to/doc, apify://actor/run/dataset
PromptsReusable prompt templates"Summarize this markdown," "Generate a scraper"

Tools are the most common. The AI sees the tool schema (name, description, parameters) and decides when to call it. Resources let the AI pull in documents or data by URI without an explicit tool call. Prompts standardize common workflows so users can trigger them with one click.

How MCP Differs from Function Calling

AttributeMCP ServersOpenAI Function CallingLangChain Tools
ConnectionPersistent, bidirectionalPer-request, statelessPer-chain, in-process
Client flexibilityAny MCP host uses any serverTied to OpenAI SDKTied to LangChain
DiscoveryServer advertises at connectDefined per appDefined per chain
DeploymentRun as separate processInline in codeInline in code

MCP is designed for tool as a service: you deploy a server once, and multiple applications can use it. OpenAI's function calling is request-scoped: you pass tool definitions with every API call. LangChain tools live inside your Python or JS process. MCP sits in the middle: shared, persistent, and protocol-based. Worth noting, OpenAI's own platform now supports MCP too, so the line between these approaches is blurring.

Building an MCP Server

Use the official SDKs:

  • TypeScript/Node: @modelcontextprotocol/sdk
  • Python: mcp package

A minimal server exposes one or more tools. Here's a TypeScript example with a get_weather tool:

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

const server = new McpServer({ name: "weather-server", version: "1.0.0" });

server.tool("get_weather", "Get current weather for a city", {
city: { type: "string", description: "City name" },
}, async ({ city }) => {
const res = await fetch(`https://api.example.com/weather?city=${city}`);
const data = await res.json();
return { content: [{ type: "text", text: JSON.stringify(data) }] };
});

async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
}
main();

Run with node server.js. Add to Claude's MCP config:

{
"mcpServers": {
"weather": {
"command": "node",
"args": ["/path/to/server.js"]
}
}
}

Claude can now call get_weather when you ask about the weather.

ServerCapabilityUse Case
ApifyRun Actors, read datasetsWeb scraping, data extraction
FirecrawlScrape URLs to markdownRAG, content ingestion
Bright DataProxy + Scraping BrowserAnti-bot sites
GitHubRepos, issues, PRsCode assistant
PostgresQuery databaseData analysis
FilesystemRead/write local filesDoc editing, config

The Apify MCP server is especially useful for AI-driven scraping: Claude can trigger Actors, wait for results, and feed data into the conversation. Apify offers two ways to connect: a hosted server at https://mcp.apify.com/?fpr=use-apify (OAuth-based, recommended, exposes 30,000+ Actors) or a local server via npx -y @apify/actors-mcp-server. See Apify Claude Desktop MCP for setup. If you want to follow along hands-on, you can try Claude free for a week and wire up your first server.

Comparison: MCP vs OpenAI Function Calling vs LangChain Tools

AttributeMCPOpenAI Function CallingLangChain Tools
ScopeCross-application, sharedPer-requestPer-chain
PersistenceLong-lived serverStatelessIn-process
EcosystemGrowing (Claude, Cursor, etc.)OpenAI-onlyLangChain-only
SetupSeparate process, configSDK + schemaPython/JS imports
Best forClaude, multi-app toolingChatGPT appsPython pipelines

Use MCP when you want Claude (or similar) to access tools without rebuilding them into each app. Use OpenAI function calling for ChatGPT-specific integrations. Use LangChain tools when you're already in a LangChain pipeline.

Transport Options: stdio vs HTTP

MCP servers can run locally (stdio) or remotely (Streamable HTTP). For local setups, stdio is the default: the host spawns the server as a subprocess and communicates via stdin and stdout. For remote servers, the current spec uses Streamable HTTP (the older HTTP+SSE transport still exists in some servers but is being phased out) so the host can connect to a URL. Remote servers enable sharing a single deployment across multiple users or applications. When building custom servers, start with stdio for simplicity, then move to remote HTTP when you need centralized deployment or cross-machine access.

Integrating with Apify

The Apify MCP server exposes tools like run_actor and get_dataset. Claude can run the Website Content Crawler, Google Search Scraper, or any custom Actor. Results are returned as context for the next turn. This pairs well with Firecrawl MCP for hybrid workflows: Firecrawl for quick markdown, Apify for complex crawls and custom logic.

Apify Affiliate Banner 728x90Apify Affiliate Banner 728x90Apify Affiliate Banner 300x50Apify Affiliate Banner 300x50
Start with one server

Add the Apify or Firecrawl MCP server first. Get comfortable with tool calls and resources, then build a custom server for your own APIs.



Try Apify MCP | Automate with Make | Firecrawl MCP Setup

Frequently Asked Questions

The Model Context Protocol (MCP) is Anthropic's open standard for connecting AI assistants to external tools. MCP servers expose tools, resources, and prompts that hosts like Claude Desktop can call.

Add a server entry to Claude's MCP config (claude_desktop_config.json or Cursor settings). Specify command and args for local stdio servers, or a URL for remote Streamable HTTP servers. In Claude Desktop you can also add remote servers through the connectors UI.

MCP uses persistent servers that any MCP host can use. OpenAI function calling is per-request and tied to the OpenAI API. MCP is more reusable across applications.

Yes. Use the mcp Python package. Define tools with @server.tool decorator, implement handlers, and run with stdio or HTTP transport.

The official Apify MCP server lets Claude run Actors and read datasets. You can also build custom MCP servers that call the Apify API.

Yes. Cursor supports MCP servers. Configure them in Cursor settings. Many MCP servers (Apify, Firecrawl, Filesystem) work with both Claude Desktop and Cursor.

Common mistakes and fixes

MCP server not detected by Claude

Ensure the server runs via stdio and outputs valid JSON-RPC. Check Claude's MCP config path and restart Claude Desktop.

Tool calls timeout or fail

Add retries in the server. Ensure external APIs (e.g., Apify) return within 30 to 60 seconds or use async webhooks.