An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
{
"ID": "20260804223002-mcpsv03",
"Spec": "2",
"Type": "NodeDocument",
"Properties": {
"id": "20260804223002-mcpsv03",
"title": "MCP Service",
"type": "doc",
"updated": "20261024164212"
},
"Children": [
{"ID": "20260804223101-mcpen01", "Type": "NodeHeading", "HeadingLevel": 2, "Properties": {"id": "20260804223101-mcpen01", "updated": "20260804230000"}, "Children": [{"Type": "NodeText", "Data": "Overview"}]},
{"ID": "20260804223102-mcpen02", "Type": "NodeParagraph", "Properties": {"id": "20260804223102-mcpen02", "updated": "20260804230000"}, "Children": [{"Type": "NodeText", "Data": "SiYuan includes an MCP server that lets external MCP clients discover and call SiYuan tools to search, read, and operate on the current workspace. This is the opposite direction from the external MCP services configured for the AI agent: external clients connect to the former, while the SiYuan agent connects to the latter."}]},
{"ID": "20260804223103-mcpen03", "Type": "NodeHeading", "HeadingLevel": 2, "Properties": {"id": "20260804223103-mcpen03", "updated": "20261024163013"}, "Children": [{"Type": "NodeText", "Data": "Connect to the service"}]},
{"ID": "20260804223104-mcpen04", "Type": "NodeParagraph", "Properties": {"id": "20260804223104-mcpen04", "updated": "20260804230000"}, "Children": [{"Type": "NodeText", "Data": "Make sure SiYuan is running and the MCP client can reach its network address. The service uses Streamable HTTP at the fixed endpoint "}, {"Type": "NodeTextMark", "TextMarkType": "code", "TextMarkTextContent": "/mcp"}, {"Type": "NodeText", "Data": ". The default local address is usually "}, {"Type": "NodeTextMark", "TextMarkType": "code", "TextMarkTextContent": "http://127.0.0.1:6806/mcp"}, {"Type": "NodeText", "Data": ". For a remote connection, replace the host and port with the reachable SiYuan address."}]},
{"ID": "20260804223105-mcpen05", "Type": "NodeParagraph", "Properties": {"id": "20260804223105-mcpen05", "updated": "20261024163013"}, "Children": [
{
"Type": "NodeText",
"Data": "View or set the API token in "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Settings"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Authentication"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Login and tokens"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "API token"
},
{
"Type": "NodeText",
"Data": ", then set "
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "Authorization: Token {Your API Token}"
},
{
"Type": "NodeText",
"Data": " in the client request headers."
}
]},
{"ID": "20260804223106-mcpen06", "Type": "NodeCodeBlock", "IsFencedCodeBlock": true, "CodeBlockFenceChar": 96, "CodeBlockFenceLen": 3, "CodeBlockOpenFence": "YGBg", "CodeBlockInfo": "anNvbg==", "CodeBlockCloseFence": "YGBg", "Properties": {"id": "20260804223106-mcpen06", "updated": "20260804230000"}, "Children": [{"Type": "NodeCodeBlockFenceOpenMarker", "Data": "```", "CodeBlockFenceLen": 3}, {"Type": "NodeCodeBlockFenceInfoMarker", "CodeBlockInfo": "anNvbg=="}, {"Type": "NodeCodeBlockCode", "Data": "{\n \"mcpServers\": {\n \"siyuan\": {\n \"url\": \"http://127.0.0.1:6806/mcp\",\n \"headers\": {\n \"Authorization\": \"Token {Your API Token}\"\n }\n }\n }\n}\n"}, {"Type": "NodeCodeBlockFenceCloseMarker", "Data": "```", "CodeBlockFenceLen": 3}]},
{"ID": "20260804223107-mcpen07", "Type": "NodeParagraph", "Properties": {"id": "20260804223107-mcpen07", "updated": "20260804230000"}, "Children": [{"Type": "NodeText", "Data": "This is a generic configuration example. Configuration file locations and field names vary among MCP clients, so follow the client documentation. The essential settings are the Streamable HTTP URL and the authentication header."}]},
{"ID": "20260804223108-mcpen08", "Type": "NodeHeading", "HeadingLevel": 2, "Properties": {"id": "20260804223108-mcpen08", "updated": "20260804230000"}, "Children": [{"Type": "NodeText", "Data": "Tool capabilities"}]},
{"ID": "20260804223109-mcpen09", "Type": "NodeParagraph", "Properties": {"id": "20260804223109-mcpen09", "updated": "20260804230000"}, "Children": [{"Type": "NodeText", "Data": "After connecting, the client dynamically discovers the available tools. Built-in tools cover search, documents, blocks, notebooks, databases, assets, history, import and export, synchronization, and more. The tool set may vary with the SiYuan version and runtime environment, so use the result discovered by the client."}]},
{"ID": "20260804223110-mcpen10", "Type": "NodeHeading", "HeadingLevel": 2, "Properties": {"id": "20260804223110-mcpen10", "updated": "20260804230000"}, "Children": [{"Type": "NodeText", "Data": "Permissions and security"}]},
{"ID": "20260804223111-mcpen11", "Type": "NodeParagraph", "Properties": {"id": "20260804223111-mcpen11", "updated": "20260804230000"}, "Children": [{"Type": "NodeText", "Data": "The MCP endpoint only accepts authenticated administrator access. The API token represents administrator access to the workspace. A connected client can read data and may modify or delete data, access workspace files, execute SQL, or trigger synchronization, so only connect trusted clients."}]},
{"ID": "20260804223112-mcpen12", "Type": "NodeParagraph", "Properties": {"id": "20260804223112-mcpen12", "updated": "20260804230000"}, "Children": [{"Type": "NodeText", "Data": "Read-only mode rejects MCP POST and DELETE requests, so tools cannot be used normally. Do not expose the SiYuan service port directly to an untrusted network. For remote access, use HTTPS, a reverse proxy, or a firewall, and replace the token immediately if it is exposed."}]},
{"ID": "20260804223113-mcpen13", "Type": "NodeParagraph", "Properties": {"id": "20260804223113-mcpen13", "updated": "20260804230000"}, "Children": [{"Type": "NodeText", "Data": "To operate SiYuan directly through HTTP endpoints, see "}, {"Type": "NodeTextMark", "TextMarkType": "block-ref", "TextMarkBlockRefID": "20201227201751-gv0fpx2", "TextMarkBlockRefSubtype": "s", "TextMarkTextContent": "Kernel API"}, {"Type": "NodeText", "Data": ". To configure external MCP services for the SiYuan AI agent, see "}, {"Type": "NodeTextMark", "TextMarkType": "block-ref", "TextMarkBlockRefID": "20260804171004-aiagt03", "TextMarkBlockRefSubtype": "s", "TextMarkTextContent": "AI Agent"}, {"Type": "NodeText", "Data": "."}]},
{"ID": "20260926135700-qwphgrd", "Type": "NodeHeading", "Properties": {"id": "20260926135700-qwphgrd", "updated": "20261024164212"}, "Children": [{"Type": "NodeText", "Data": "OAuth connections"}], "HeadingLevel": 2},
{"ID": "20260926135700-ob3m8qh", "Type": "NodeParagraph", "Properties": {"id": "20260926135700-ob3m8qh", "updated": "20261024163013"}, "Children": [
{"Type": "NodeText", "Data": "Open "},
{"Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "Settings"},
{"Type": "NodeText", "Data": " - "},
{"Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "Artificial Intelligence"},
{"Type": "NodeText", "Data": " - "},
{"Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "MCP"},
{"Type": "NodeText", "Data": " to configure MCP server OAuth. It is disabled by default and requires a lock screen password or OIDC login. Enter the public HTTPS origin, such as https://note.example.com, without a path. The MCP address is https://note.example.com/mcp; the reverse proxy must preserve the public Host and forward /.well-known/ and /oauth/mcp/ as well as /mcp and the login page."}
]},
{"ID": "20260926135700-qek3gz7", "Type": "NodeParagraph", "Properties": {"id": "20260926135700-qek3gz7", "updated": "20260926135700"}, "Children": [{"Type": "NodeText", "Data": "Register a client using its name and the exact callback URL shown by the MCP client, such as ChatGPT. Save the client ID and secret immediately; the secret is displayed only once. Enter both in the client’s OAuth connection settings, connect to the MCP address, sign in to SiYuan and confirm authorization. Dynamic client registration is not supported."}]},
{"ID": "20260926135700-3re293l", "Type": "NodeParagraph", "Properties": {"id": "20260926135700-3re293l", "updated": "20260926135700"}, "Children": [{"Type": "NodeText", "Data": "Authorization allows all MCP tools currently exposed by this workspace, including read, write, delete and administration capabilities. OAuth tokens work only on /mcp. Read-only mode and encrypted notebook locks still apply; authorization does not unlock notebooks. Existing API token connections continue to work."}]},
{"ID": "20260926135700-79q86ot", "Type": "NodeParagraph", "Properties": {"id": "20260926135700-79q86ot", "updated": "20261024164212"}, "Children": [
{"Type": "NodeText", "Data": "Access tokens expire after one hour. Clients requesting offline_access receive rotating refresh tokens valid for up to thirty days from authorization. Removing a client revokes its tokens; Revoke all authorizations retains client registrations."}
]},
{
"ID": "20261024164212-jhxgkyz",
"Type": "NodeParagraph",
"Properties": {
"id": "20261024164212-jhxgkyz",
"updated": "20261024164212"
},
"Children": [
{
"Type": "NodeText",
"Data": "Disabling OAuth, changing the public origin or changing administrator authentication configuration revokes existing authorizations. The configuration and credential hashes are stored locally in conf/mcp-oauth.json; keep this file private and do not share it between workspaces."
}
]
}
]
}