{"slug": "model-context-protocol-tutorial", "title": "Model Context Protocol tutorial", "summary": "Anthropic's Model Context Protocol (MCP) enables developers to give AI models direct access to tools and real-time data, transforming workflows from copy-pasting code to querying databases and files directly. The tutorial demonstrates configuring filesystem and Fetch MCP servers in Claude Desktop, showing time savings from 15 minutes to 30 seconds for refactoring tasks, and highlights the ease of building custom MCP servers using the MCP SDK.", "body_md": "# Model Context Protocol tutorial\n\nMost developers use Claude or [Cursor](/en/tags/cursor/) by copy-pasting code blocks or relying on built-in indexing that occasionally hallucinates. It's tedious. Then Anthropic dropped the Model Context Protocol (MCP), and suddenly the game changed from \"asking the AI to guess\" to \"giving the AI a set of tools.\" If you haven't set up an MCP server yet, you're essentially using a Ferrari in a school zone.\n\n## Forget the fluff, here is a Model Context Protocol tutorial for people who actually code\n\nThe core idea of [MCP](/en/tags/mcp/) is simple: instead of the LLM trying to \"know\" everything, it uses a standardized protocol to call \"tools\" (small pieces of code) that fetch real-time data. Think of it as a USB port for LLMs.\n\nI spent last Thursday afternoon fighting with a legacy Postgres database where the schema was a nightmare. Normally, I'd spend an hour exporting DDLs to a text file so [Claude](/en/tags/claude/) could understand the relations. With an MCP server for Postgres, I just asked, \"Which tables are linked to the user_sessions table?\" and it queried the database directly.\n\n### Tip 1: Connect your local filesystem without the \"upload\" dance\n\nStop dragging and dropping files into a chat window. If you're using Claude Desktop, you can configure the filesystem MCP server to give the AI read/write access to specific folders.\n\n**The Use Case:** You have a massive monorepo with 400+ files. You need to refactor a utility function used in 12 different places.\n\n**The Config (claude_desktop_config.json):**\n\n```\n{\n  \"mcpServers\": {\n    \"filesystem\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-filesystem\", \"/Users/yourname/projects/my-app\"]\n    }\n  }\n}\n```\n\n**Before:** You copy the function, copy the 12 call sites, ask for the fix, and then manually paste the fix into 12 files. Total time: 15 minutes. High chance of a typo.\n\n**After:** \"Refactor the `formatDate`\n\nutil in `/utils/date.ts`\n\nto handle UTC offsets, then update all callers in the project.\" Total time: 30 seconds. The AI reads the files, writes the changes, and you just hit 'Save'.\n\n### Tip 2: Bridge the gap between API docs and actual implementation\n\nDocumentation changes faster than LLM training cuts. If you're using a library that updated three weeks ago, the AI is lying to you. Use the Fetch MCP server to let the AI read the live docs.\n\n**The Use Case:** Implementing a new feature using a beta version of a framework where the syntax just changed.\n\n**Before:** AI suggests `useAsyncEffect()`\n\n(deprecated). You get a runtime error. You search the docs. You tell the AI it's wrong. You paste the new docs.\n\n**After:** \"Fetch the latest API reference from `https://docs.example.com/beta/hooks`\n\nand rewrite this component using the new pattern.\"\n\n| Method | Accuracy | Speed | Friction |\n\n| :--- | :--- | :--- | :--- |\n\n| Training Data | Low (Outdated) | Instant | None |\n\n| Manual Paste | High | Slow | High |\n\n| MCP Fetch | High (Live) | Fast | Low |\n\n## Getting your hands dirty with custom MCP servers\n\nThe real magic happens when you stop using the pre-built servers and write your own. Since MCP is just JSON-RPC over stdio or HTTP, you can wrap literally any internal script in an MCP server.\n\nI wrote a 20-line TypeScript server last week that connects to my Jira board. Now, instead of switching tabs to check what \"Ticket-402\" actually asks for, I just say \"Look at Ticket-402 and implement the fix in the current file.\"\n\nIf you're looking for a head start on this, browsing [Prompt Sharing](/en/category/prompts/) is a great way to see how others are structuring their requests to trigger these tools effectively.\n\n### The \"Quick-Start\" logic for a custom server\n\nIf you want to build one, don't overthink it. Use the MCP SDK.\n\n1. Define a **Tool**: Give it a name (e.g., `get_customer_logs`\n\n) and a schema (e.g., `customer_id: string`\n\n).\n\n2. Implement the **Handler**: Write the JS/Python code that actually hits the API or DB.\n\n3. Register it in your **Config**: Add the command to your `claude_desktop_config.json`\n\n.\n\n### Tip 3: Combining MCP with [RAG](/en/tags/rag/) for \"Hyper-Context\"\n\nRAG (Retrieval-Augmented Generation) is great for static knowledge. MCP is great for dynamic action. When you combine them, you get a system that doesn't just know your codebase—it knows the state of your app.\n\n**The Use Case:** Debugging a production error that only happens for one specific user ID.\n\n**The Workflow:**\n\n1. AI uses a Log-MCP server to fetch the last 50 lines of the error log.\n\n2. AI identifies the `user_id`\n\ncausing the crash.\n\n3. AI uses a DB-MCP server to check that user's configuration in the database.\n\n4. AI finds a null value in a required field.\n\n**Before:** Log search → DB query → Code search → Realization. (10 minutes).**After:** \"Why is user 8821 crashing?\" → \"They have a null locale setting in the DB.\" (5 seconds).\n\n## Why you should actually care about a community like PromptCube\n\nSetting up MCP is the \"easy\" part. The hard part is discovering which servers actually save time and which ones are just bloat. Most of the \"official\" docs are dry. You need to see how people are actually wiring these things together in production.\n\nJoining a community like PromptCube isn't about reading more manuals. It's about finding the guy who already spent six hours debugging a connection issue between an MCP server and a Docker container so you don't have to. It's where you find the \"hidden\" configs and the niche servers that aren't listed in the top 10 GitHub repos.\n\nTo get in, you just sign up and start diving into the discussions. Whether you're arguing about Claude 3.5 Sonnet vs. GPT-4o for Python refactoring or sharing a new MCP server for a niche API, it's the fastest way to stop guessing and start shipping.\n\n## A final sanity check on your setup\n\nIf your MCP tools are feeling sluggish, check your `npx`\n\ncalls. Running things via `npx`\n\nevery time the AI wakes up can add a noticeable lag. Install the servers globally using `npm install -g`\n\nand change your config to call the binary directly. I measured a 1.2s difference in response time just by doing that. It sounds small until you've called a tool 50 times in an hour.\n\nThe shift from \"Chatting with AI\" to \"Operating AI\" happens exactly here. Once you move your context from your clipboard to the protocol, you'll realize you've been working in a very limited way for the last two years.\n\n[Next Apple is finally building its own LLM for China with Alibaba's →](/en/news/6290/)\n\n## All Replies （0）\n\nNo replies yet — be the first!", "url": "https://wpnews.pro/news/model-context-protocol-tutorial", "canonical_source": "https://promptcube3.com/en/threads/6293/", "published_at": "2026-08-14 15:50:14+00:00", "updated_at": "2026-08-14 16:26:02.719993+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "artificial-intelligence"], "entities": ["Anthropic", "Claude", "Cursor", "Model Context Protocol", "MCP SDK", "Jira", "Postgres"], "alternates": {"html": "https://wpnews.pro/news/model-context-protocol-tutorial", "markdown": "https://wpnews.pro/news/model-context-protocol-tutorial.md", "text": "https://wpnews.pro/news/model-context-protocol-tutorial.txt", "jsonld": "https://wpnews.pro/news/model-context-protocol-tutorial.jsonld"}}