My First MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@My First MCPsummarize report.txt and compare it to spec.md"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
My First MCP
A learning project to understand the Model Context Protocol (MCP) — tools, resources, and prompts — by building a CLI chatbot that talks to documents.
Project Structure
├── core/
│ ├── __init__.py
│ └── documents.py # Mock document store with Pydantic models
├── mcp_server.py # MCP Server — tools, resources, and prompts
├── mcp_client.py # MCP Client — test all three primitives directly
├── main.py # CLI Chatbot — Claude agent with /commands
├── requirements.txt
├── .env # Your API key (git-ignored, never committed)
├── .gitignore
└── README.mdRelated MCP server: MinerU Document Explorer
How the pieces connect
User → main.py (CLI Chatbot) → Claude API
↕ ↕
MCP Client "Use read_doc tool"
↕
MCP Server (mcp_server.py, spawned as subprocess)
↕
core/documents.py (Pydantic models + mock data)Setup
python -m venv .venv
source .venv/bin/activate # macOS/Linux
# .venv\Scripts\activate # Windows
pip install -r requirements.txtAdd your API key to .env:
ANTHROPIC_API_KEY=sk-ant-...Running
1. Test the server with MCP Inspector (no code needed):
mcp dev mcp_server.pyOpens a browser UI where you can browse tools/resources/prompts and call them interactively.
2. Test the client directly (no AI):
python mcp_client.py3. Run the chatbot:
python main.pyStep-by-Step Development Roadmap
Work through these in order. Each step builds on the last.
Phase 1: Understand the Server (mcp_server.py)
Run the server in MCP Inspector (
mcp dev mcp_server.py). Click around the Tools tab. Callread_docwith different document names. Call it with a name that doesn't exist — observe the error format.Add the
list_docstool. You have the function incore/documents.pyalready. Register it with@mcp.tool(). Restart the inspector and verify it appears.Uncomment and test resources in
mcp_client.py. Read thedocs://listresource. Then add individual document resources using a URI template (docs://{doc_name}) on the server. Resources are the "browse" side of MCP vs tools being the "do" side.Uncomment and test prompts in
mcp_client.py. Callget_prompt("summarize_doc", ...)and look at what comes back — it's a message structure, not a raw string. Add acompare_docsprompt that takes two document names.
Phase 2: Understand the Client (mcp_client.py)
Trace the lifecycle. Add print statements at each stage: connection, initialize handshake, list_tools, call_tool. Understand the
ClientSessionobject — it's your handle to everything.Call update_doc then read_doc. Verify state changes persist within a session. Think about why they DON'T persist across sessions (the server restarts).
Try error cases. Call a tool with wrong argument types. Call a non-existent tool. Read a non-existent resource URI. Understand how MCP surfaces errors.
Phase 3: Build the Agent Loop (main.py)
Study
agent_turn(). This is the heart of every AI agent. The loop is: send to Claude → check if it wants a tool → call the tool via MCP → feed result back → repeat. Trace through it with a simple prompt like "what's in report.txt?"Study
handle_slash_command(). See how MCP prompts become/commands. The server defines the templates, the client presents them. Try/summarize_doc spec.mdand watch the prompt get fetched from the server, sent to Claude, which then calls theread_doctool.Add multi-turn awareness. Currently the chatbot maintains history. Try "what's in report.txt?" then "now update it with a new section" — observe how Claude uses context from prior turns.
Phase 4: Extend It (your own features)
Add a
compare_docsprompt on the server that takes two document names. Wire it into the chatbot as/compare_docs. Think about how to parse multiple arguments from one string.Add resource templates for individual documents (
docs://{doc_name}). Then in the chatbot, add a/browsecommand that lists resources and lets you read one.Add a
search_docstool that takes a query string and searches document contents. This is a good exercise in writing tool descriptions that help Claude understand when to use it vsread_doc.Think about what's missing for production: persistent storage, authentication, error handling, rate limiting, logging. You don't need to build these — just note where they'd go.
Phase 5: Ship It
Double-check
.gitignore— make sure.envand.venv/are listed. Rungit statusbefore committing to verify no secrets leak.Init the repo and push:
git init
git add .
git commit -m "Initial commit: MCP learning project"
git remote add origin <your-github-url>
git push -u origin mainThis server cannot be deployed
Maintenance
Related MCP Connectors
Versioned documentation registry and semantic search for AI tools and coding assistants.
Ingest, manage, and retrieve documents for RAG-powered AI applications
Search, fetch (with provenance), scan, and convert AI instruction files for agents.
Persistent docs and memory for AI agents — read, write, organize & search a shared workspace.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables accessing and managing personal/team internal knowledge repository with tools for semantic search, smart search, document listing, and saving information for future recall.Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to search, deep-read, and build knowledge bases from Markdown, PDF, DOCX, and PPTX documents via MCP tools for retrieval, document navigation, and ingestion.16631MIT
- FlicenseNot gradedqualityDmaintenanceProvides tools for indexing documents, creating notes, searching content, and extracting metadata to enable document processing and knowledge management.-
- FlicenseNot gradedqualityDmaintenanceEnables AI systems to store and search resources with fuzzy search, regex, and tag filtering, with domain isolation and prompt template management.-