mcp-toolkit-server
An MCP server providing secure calculation, knowledge base search, and text statistics tools, along with resources and prompts for enterprise agent integration.
README
mcp-toolkit-server
A custom Model Context Protocol (MCP) server exposing a small, composable registry of tools, resources, and prompts — the pattern behind "wrap it once, every agent gets access" enterprise tool integration.
Why this exists
MCP is the standardized layer that lets an agent framework (LangGraph, Claude Agent SDK, a custom orchestrator) discover and call tools without bespoke integration code per agent. I've built MCP server implementations against internal enterprise systems (knowledge bases, policy document APIs, compliance tools) in production; this project is a small, self-contained MCP server built from scratch to show the same pattern — a tool/resource/prompt registry with real JSON Schema contracts — in a form that's inspectable end to end.
What it exposes
MCP defines three primitive types. This server implements all three:
| Type | Name | What it does |
|---|---|---|
| Tool | calculate |
Evaluates a numeric expression via a whitelisted AST walk (not eval) |
| Tool | search_knowledge_base |
Keyword-overlap search over a bundled document set |
| Tool | text_stats |
Character/word/sentence counts and estimated reading time |
| Resource | kb://documents |
Lists available knowledge-base document names |
| Resource | kb://document/{name} |
Fetches one document's full text (URI template) |
| Prompt | summarize_document |
A reusable, parameterized prompt template |
Installation
git clone https://github.com/varunram3232-glitch/mcp-toolkit-server.git
cd mcp-toolkit-server
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
Running the server
Over stdio (the transport Claude Desktop and most local MCP clients use):
mcp-toolkit-server
With the MCP Inspector, for interactive development:
mcp dev src/mcp_toolkit/server.py
Connecting it to Claude Desktop — add to your claude_desktop_config.json:
{
"mcpServers": {
"toolkit": {
"command": "/absolute/path/to/.venv/bin/mcp-toolkit-server"
}
}
}
Example: calling it programmatically
Tools are callable through the FastMCP server object directly (useful for testing, or for embedding this server's logic in another Python process without a subprocess transport):
import asyncio
from mcp_toolkit.server import mcp
async def main():
result = await mcp.call_tool("calculate", {"expression": "2 * (3 + 4) / 7"})
print(result[0].text) # "2.0"
docs = await mcp.call_tool("search_knowledge_base", {"query": "tool schema"})
print(docs[0].text)
asyncio.run(main())
Design decisions
- A real AST walk for
calculate, nevereval. Tool arguments come from a language model's interpretation of a user prompt — treating that as trusted input toeval()is a textbook injection risk.calculator.pyparses the expression into an AST and only evaluates a fixed whitelist of numeric operators; anything else (__import__, attribute access, comprehensions, name lookups) is rejected before it ever executes. - The description field is the real interface. A tool's JSON Schema tells a model what arguments are valid; the natural-language description is what tells it when to call the tool at all. Every tool and the server's top-level
instructionsare written to be specific about that ("usecalculateinstead of computing it yourself") rather than a generic one-liner. - Resources vs. tools, used for what each is for. The knowledge base is exposed as a resource (
kb://document/{name}) so a client can attach a specific document to context deliberately (like a file picker), separately fromsearch_knowledge_base, which is a tool the model decides to invoke based on the conversation. Collapsing these into one mechanism is a common MCP design mistake this repo deliberately avoids. - Dependency-free knowledge base. Search here is keyword overlap, not embeddings — this repo is about the MCP server/tool-registry pattern, not retrieval quality. See agentic-rag-assistant for a real embedding-based RAG pipeline that a production version of this tool would call into.
Testing
pip install -e ".[dev]"
pytest -v
ruff check src tests
39 tests, split across two layers:
- Unit tests for the pure logic (
test_calculator.py,test_knowledge_base.py,test_text_stats.py) — including a dedicated set of injection-attempt expressions (__import__,open(...), list comprehensions) that the calculator must reject. - Protocol-level integration tests (
test_server_integration.py) that call the real FastMCP server object'slist_tools/call_tool/list_resources/read_resource/list_prompts/get_prompt— verifying the MCP contract itself, not just the functions behind it.
Project structure
src/mcp_toolkit/
├── server.py # FastMCP instance — tool/resource/prompt registration
├── tools/
│ ├── calculator.py # AST-walking safe expression evaluator
│ ├── knowledge_base.py # In-memory document store + keyword search
│ └── text_stats.py # Text analysis
└── data/ # Bundled knowledge-base documents
Roadmap
- [ ] Streamable HTTP transport for remote deployment
- [ ] Auth middleware example (API key / OAuth) for a non-stdio deployment
- [ ] A tool that calls out to agentic-rag-assistant for embedding-based search
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。