Knowledge Base MCP
Knowledge provides MCP interface support, enabling Codex, Claude Code, and Cherry Studio clients with MCP capability to directly access files, web pages, and retrieval capabilities within the knowledge base.
Prerequisites
- Install the latest version of the knowledge base; installation instructions are available at Installation Methods.
- This document is based on the current knowledge base repository version
1.3.40. - If using the desktop MCP client, it is recommended to generate an access token for the corresponding user.
Service Endpoints
- Knowledge Application URL:
- MCP Endpoint:
- Protocol:
Streamable HTTP
Authentication Method
sshLogin to LCMD.- Execute the following command to generate a token for users who need to access the knowledge base:
hc api_auth_token gen --uid <uid>- In the MCP client configuration, pass this token via
Lzc-Api-Auth-Token.
Tool Description
The knowledge base MCP organizes tools under three namespaces: rag, fs, and ws. Many MCP clients will display them as rag_search, fs_ls, ws_ls respectively.
rag
rag_search: Search for relevant fragments in the knowledge base.rag_summarize: Perform summary analysis on a specified file or web page.rag_read: Paginated reading of file or web page content.
fs
fs_ls: List the directory structure of knowledge base files.fs_search: Search files or directories by keyword.fs_find: Find a file by filename.fs_traverse: Recursively traverse directories.fs_get_info: View details of a file or directory.fs_get_stats:Check file system statistics.fs_sync:Sync knowledge base file status.fs_mkdir、fs_rm、fs_mv、fs_update_meta:Create, delete, move, update metadata.
ws
ws_ls:List web knowledge directory.ws_search:Search saved web pages.ws_get_stats:View web knowledge statistics.ws_mkdir、ws_delete、ws_update_meta:Manage web directory and metadata.
fs_mkdir、fs_rm、fs_mv、fs_update_meta、ws_mkdir、ws_delete、ws_update_metaare write operations that modify knowledge base content. These should be used only after confirming the correct scope.
MCP Example
Note: Replace
xxxwith your LCMD name in the configuration below.
Claude Code Configuration
Edit the Claude Code configuration file ~/.claude.json, and add the following MCP server configuration:
{
"mcpServers": {
"knowledge": {
"type": "http",
"url": "https://knowledge.xxx.heiyu.space/mcp/",
"headers": {
"Lzc-Api-Auth-Token": "<token>"
}
}
}
}Codex Configuration
Edit the Codex configuration file ~/.codex/config.toml, and add the following MCP server configuration:
[mcp_servers]
[mcp_servers.knowledge]
type = "http"
url = "https://knowledge.xxx.heiyu.space/mcp/"
[mcp_servers.knowledge.http_headers]
Lzc-Api-Auth-Token = "<token>"AI Dialogue Client Configuration
Using Cherry Studio as an example, configure the following settings under Settings -> MCP Server:
- Name:
knowledge - Type: Streamable HTTP (
streamableHttp) - URL:
https://knowledge.xxx.heiyu.space/mcp/ - Header:
Lzc-Api-Auth-Token: <token>
After saving, enable the MCP server. The knowledge base tools will then appear in the tool list.
Common Usage Scenarios
- Query "the document conclusions in the knowledge base regarding a specific topic" within
Codex. - First list
/or files under a specific directory, then perform retrieval within that directory scope. - Generate a summary of a document directory, then further examine the matched segments.
- Search for previously saved web content within the knowledge base, rather than re-scraping live web pages.
Parameter Descriptions
<uid>: User ID required to access the knowledge base.<token>: Access token generated viahc api_auth_token gen.<微服名称>: Current LCMD name, corresponding toknowledge.<微服名称>.heiyu.space.