# Complete Guide to Wiki Tools in TencentDB Agent Memory

> Explore seven read-only Wiki tools in TencentDB Agent Memory. Discover how LLM agents query wiki metadata and content via HTTP endpoints for comprehensive knowledge access.

- Repository: [Tencent Cloud/TencentDB-Agent-Memory](https://github.com/TencentCloud/TencentDB-Agent-Memory)
- Tags: how-to-guide
- Published: 2026-08-27

---

**The TencentDB Agent Memory repository exposes seven read-only Wiki tools—`get_info`, `search`, `list_pages`, `read_page`, `get_graph`, `list_raw`, and `read_raw`—that LLM agents invoke via HTTP endpoints to query wiki metadata, content, and knowledge graphs without write permissions.**

TencentDB Agent Memory provides an LLM-agnostic interface for interacting with documentation wikis through the Knowledge Tools API. These tools are defined in [`MemoryKnowledge/src/routes/tools.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/routes/tools.ts) and enable secure, read-only access to wiki resources, allowing agents to search documentation, traverse knowledge graphs, and retrieve source files programmatically.

## Tool Architecture and Endpoints

### Discovery and Execution Interface

All Wiki tools are exposed through two primary HTTP endpoints implemented in [`MemoryKnowledge/src/routes/tools.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/routes/tools.ts). The `POST /tools/list` endpoint returns the available tool catalog for a specific wiki resource, while `POST /tools/call` handles the actual execution. Every request requires an `x-tdai-service-id` header for service authentication and a `knowledge_id` parameter to identify the target wiki resource.

### Whitelist Security Model

The system enforces a strict whitelist at line 70 of the tools route file. The `WIKI_TOOLS` registry contains an array of `HttpToolDef` objects that explicitly define permitted operations. Any attempt to invoke an undefined tool results in a `403` error, ensuring agents operate within a secure, read-only boundary.

## The Seven Available Wiki Tools

### get_info

Retrieves comprehensive metadata about the wiki, including its name, processing status, and total page count. According to the source code in [`MemoryKnowledge/src/routes/tools.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/routes/tools.ts) (lines 51-54), this tool maps to `wikiService.get` and returns core properties without accessing document content.

### search

Performs **BM25 full-text search** across all wiki pages. This tool accepts a `query` string and optional `limit` parameter (default 20), returning the most relevant documents with relevance-ranked snippets. The implementation delegates to `wikiMgr.search` in the wiki engine ([`MemoryKnowledge/src/engines/wiki/index.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/engines/wiki/index.ts)).

### list_pages

Returns a complete inventory of page references, including page IDs, titles, and file paths. This tool calls `wikiService.pageLs` to enumerate all accessible pages in the wiki structure (defined at lines 64-67).

### read_page

Retrieves full content from one or more pages identified by ID or path. The tool accepts a `refs` array parameter and executes `wikiService.pageReadMany` to fetch the actual markdown or text content (lines 69-74).

### get_graph

Returns the **knowledge-graph representation** of the wiki, including nodes, edges, and community clusters. This tool invokes `wikiMgr.graph` to expose structural relationships between documents (lines 76-80).

### list_raw

Enumerates the original source files uploaded to the wiki, such as markdown files and attachments. This maps to `wikiService.rawLs` and provides access to the underlying file inventory (lines 82-84).

### read_raw

Reads the complete content of specified raw source files. Using `wikiService.rawReadMany`, this tool accepts file path references and returns the unprocessed source material (lines 86-90).

## Practical Usage Examples

### Listing Available Tools for a Wiki

To discover which tools a specific wiki supports, send a POST request to the discovery endpoint:

```bash
curl -X POST https://<your-host>/v3/knowledge/<team-id>/tools/list \
     -H "Content-Type: application/json" \
     -H "x-tdai-service-id: <service-id>" \
     -d '{"knowledge_id":"my-wiki-id"}'

```

**Response excerpt:**

```json
{
  "knowledge_id": "my-wiki-id",
  "type": "wiki",
  "name": "Project Design Docs",
  "status": "ready",
  "tools": [
    {
      "name": "get_info",
      "description": "获取 wiki 元信息（名称、状态、页面数等）。",
      "params": {}
    },
    {
      "name": "search",
      "description": "BM25 全文搜索 wiki 页面内容。用关键词查找相关文档。",
      "params": {
        "query": {
          "type": "string",
          "required": true,
          "description": "搜索关键词"
        },
        "limit": {
          "type": "integer",
          "required": false,
          "default": 20,
          "description": "返回结果数上限"
        }
      }
    }
  ]
}

```

### Executing a BM25 Search

Retrieve relevant documents using the `search` tool:

```bash
curl -X POST https://<your-host>/v3/knowledge/<team-id>/tools/call \
     -H "Content-Type: application/json" \
     -H "x-tdai-service-id: <service-id>" \
     -d '{
           "knowledge_id": "my-wiki-id",
           "tool_name": "search",
           "params": {
             "query": "authentication flow",
             "limit": 5
           }
         }'

```

**Response excerpt:**

```json
{
  "results": [
    {"page_id": "12", "title": "Auth Overview", "snippet": "..."},
    {"page_id": "34", "title": "Login Process", "snippet": "..."}
  ],
  "count": 2
}

```

### Reading Specific Page Content

Fetch full document content using the `read_page` tool:

```bash
curl -X POST https://<your-host>/v3/knowledge/<team-id>/tools/call \
     -H "Content-Type: application/json" \
     -H "x-tdai-service-id: <service-id>" \
     -d '{
           "knowledge_id": "my-wiki-id",
           "tool_name": "read_page",
           "params": {
             "refs": ["/design/authentication.md"]
           }
         }'

```

**Response excerpt:**

```json
{
  "items": [
    {
      "ref": "/design/authentication.md",
      "content": "# Authentication\n\nThe system uses ..."

    }
  ]
}

```

## Implementation Architecture

When a client calls `POST /tools/call`, the router validates the `tool_name` against the whitelist, then dispatches to `executeWikiTool`. This function contains a switch statement mapping each tool name to specific service implementations:

- **get_info** → `wikiService.get`
- **search** → `wikiMgr.search`
- **list_pages** → `wikiService.pageLs`
- **read_page** → `wikiService.pageReadMany`
- **get_graph** → `wikiMgr.graph`
- **list_raw** → `wikiService.rawLs`
- **read_raw** → `wikiService.rawReadMany`

The `WikiService` and `WikiSourceManager` are injected via the `ToolsRouteDeps` interface, keeping the routing layer focused on HTTP handling while delegating business logic to [`MemoryKnowledge/src/store/wiki-service.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/store/wiki-service.ts) and the search/graph engines in [`MemoryKnowledge/src/engines/wiki/index.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/engines/wiki/index.ts). The `isWikiId` helper function in [`MemoryKnowledge/src/store/ids.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/store/ids.ts) determines whether a given `knowledge_id` qualifies for wiki tool access.

## Summary

- Seven read-only tools are available: `get_info`, `search`, `list_pages`, `read_page`, `get_graph`, `list_raw`, and `read_raw`
- Tools are exposed via `POST /tools/list` and `POST /tools/call` endpoints in [`MemoryKnowledge/src/routes/tools.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/routes/tools.ts)
- Strict whitelist enforcement at line 70 prevents unauthorized tool invocation with `403` errors
- Service layer maps tools to specific `WikiService` and `WikiSourceManager` methods
- Raw source files are accessible separately from processed page content through dedicated raw file tools

## Frequently Asked Questions

### What authentication is required to use Wiki tools?

All requests must include the `x-tdai-service-id` header and target a valid `knowledge_id` that passes the `isWikiId` check in [`MemoryKnowledge/src/store/ids.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/store/ids.ts). The system validates these credentials before exposing the tool registry or executing any tool calls.

### Can LLM agents modify wiki content using these tools?

No. The `WIKI_TOOLS` registry explicitly defines **read-only** operations. There are no write, update, or delete tools exposed through the Knowledge Tools API, and any attempt to call an undefined tool results in a `403 Forbidden` error.

### How does the search tool rank results?

The `search` tool implements **BM25 ranking** through `wikiMgr.search` in [`MemoryKnowledge/src/engines/wiki/index.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/engines/wiki/index.ts). This algorithm scores documents based on term frequency, inverse document frequency, and field length normalization to return the most relevant wiki pages for a given query.

### What is the difference between `read_page` and `read_raw`?

`read_page` accesses processed and indexed content through `wikiService.pageReadMany`, returning rendered documentation. `read_raw` retrieves the original uploaded source files (such as markdown or text files) via `wikiService.rawReadMany`, providing access to unprocessed source material without indexing overlays.