Knowledge Base Tools
Provides AI agents with tools to navigate, search, and manage a hierarchical knowledge base of themes, skills, and learning resources with tenant-aware JWT authentication.
README
MCP Server - Knowledge Base Tools
MCP (Model Context Protocol) server exposing knowledge base operations as tools for AI agents.
Overview
This MCP server provides tools for interacting with the Django backend API to manage and query the knowledge base. All tools require JWT authentication and automatically handle tenant-aware routing.
Features
- JWT Authentication: Token verification using shared secret with Django backend
- Tenant-aware: Automatically extracts tenant from JWT and routes to correct backend instance
- 8 Knowledge Base Tools: Complete set of operations for navigating and managing the knowledge graph
Installation
-
Create and activate virtual environment (recommended):
python3 -m venv venv # On macOS/Linux: source venv/bin/activate # On Windows: # venv\Scripts\activate -
Install dependencies:
pip install -r requirements.txt -
Configure environment variables:
cp .env.example .env # Edit .env with your configuration
Configuration
Environment Variables
MCP_JWT_SECRET_KEY: Secret key for JWT token verification (can useCHAINLIT_JWT_SECRET_KEYas fallback)MCP_BACKEND_URL: Backend URL with tenant placeholder, e.g.,http://tenant.localhost:8000(can useBACKEND_URLas fallback)
Example .env file:
MCP_JWT_SECRET_KEY=your-secret-key-here
MCP_BACKEND_URL=http://tenant.localhost:8000
Available Tools
1. get_root_themes_tool
Get all root theme nodes (top-level folders without parents). Entry point for navigating the knowledge base.
2. get_folder_tree_tool
Get complete folder tree under a theme node. Returns only themes recursively, excluding skills and knowledge nodes.
3. semantic_search_tool
Perform semantic search across themes, skills, and knowledge nodes using vector similarity.
4. get_node_children_tool
Get direct children of a node for downward navigation in the hierarchy.
5. get_node_parents_tool
Get direct parent nodes for upward navigation in the hierarchy.
6. create_folder_tool
Create a new theme (folder) node at root or under a parent theme.
7. create_skill_tool
Create a new skill node under a parent theme.
8. generate_learning_tools_tool
Generate learning tools (knowledge nodes with questions) for a skill using AI.
Running the Server
Make sure your virtual environment is activated before running the server.
Start the HTTP/SSE server:
# Activate venv first
source venv/bin/activate # On macOS/Linux
# venv\Scripts\activate # On Windows
python server.py
The server will start on http://0.0.0.0:8100 by default (configurable via environment variables).
Configuration options:
MCP_HOST: Host to bind (default:0.0.0.0)MCP_PORT: Port number (default:8100- port 8000 is used by the Django backend)MCP_TRANSPORT: Transport type -sse(Server-Sent Events) orstreamable-http(default:sse)
With MCP Inspector (for testing):
-
Start the server:
python server.py -
In MCP Inspector, configure the connection:
- Type:
sse - URL:
http://localhost:8100/sse(uselocalhostnot0.0.0.0in browser)
Example configuration:
{ "mcpServers": { "knowledge-base": { "type": "sse", "url": "http://localhost:8100/sse" } } }Note: The server binds to
0.0.0.0but you must uselocalhostor127.0.0.1in browser-based clients. - Type:
Usage
All tools require a jwt_token parameter containing the user's JWT authentication token. The token should:
- Be a valid JWT signed with the same secret as configured in
MCP_JWT_SECRET_KEY - Contain a
tenantclaim for tenant-aware routing - Be passed as a Bearer token or raw token string
Example tool call:
result = get_root_themes_tool(
jwt_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
)
Architecture
auth.py: JWT token verification and tenant extractiontools.py: Core tool functions that interact with Django backendserver.py: FastMCP server setup and tool registration
Security
- All tools verify JWT tokens before processing requests
- Tenant is extracted from token payload (never from user input)
- Backend URL is constructed from token, ensuring tenant isolation
- Invalid or expired tokens return error responses
Error Handling
All tools return a dictionary with:
success: trueand data on successsuccess: falseanderror: "message"on failure
Development
The server uses FastMCP, which automatically handles:
- Tool registration
- Request/response serialization
- Error handling
- Logging
Related Files
shad/agents/tools.py: Original LangChain tools (reference implementation)backend/learn/: Django backend API endpoints
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。