# How to List Available Tools for an Agent in TencentDB-Agent-Memory

> Learn how to list available tools for an agent in TencentDB-Agent-Memory. Send a POST request to /v3/tools/list to get tool details and prepare for operations.

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

---

**Send a POST request to the `/v3/tools/list` endpoint to retrieve a JSON array describing every callable tool, then execute specific operations by calling `/v3/tools/call` with the selected tool name and parameters.**

The TencentDB-Agent-Memory platform provides a self-discovery mechanism that allows LLM-driven agents to dynamically identify available capabilities without hard-coding tool names. This article explains how to list available tools for an agent using the Knowledge API endpoints, SDK implementations, and prompt injection techniques found in the TencentCloud/TencentDB-Agent-Memory source code.

## Understanding the Two-Step Tool Discovery Flow

The architecture follows a discover-then-invoke pattern. Agents first query the knowledge service to enumerate supported operations, then target specific tools by name. This design decouples the agent from implementation details, allowing the knowledge base to evolve without breaking existing agent configurations.

### Tool Discovery Endpoint

In [`MemoryKnowledge/src/routes/tools.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/routes/tools.ts), the framework exposes a dedicated listing route that returns metadata for every registered tool. According to the source code (lines 5-10 and 192-197), sending a POST request to `/<service-url>/v3/tools/list` yields a JSON array containing objects with the tool name, required parameter schema, and human-readable description.

### Tool Invocation Endpoint

Once an agent identifies a relevant tool, it calls the execution endpoint implemented in the same file (lines 271-283). The `/<service-url>/v3/tools/call` route accepts a JSON payload structured as `{"tool_name": "<NAME>", "params": {...}}`, validates the tool name against the discovery list, and routes execution to the appropriate handler.

## Listing Tools via the HTTP API

The raw HTTP interface provides the most transparent method to list available tools for an agent. Use standard `curl` commands to interact with the discovery and invocation endpoints.

### Discover Available Tools

Send an empty POST body to the list endpoint to retrieve all supported operations:

```bash
curl -sS -X POST https://your-knowledge-service/v3/tools/list \
     -H "Content-Type: application/json" \
     -d '{}'

```

The response follows this schema (truncated example):

```json
[
  {
    "name": "search",
    "params": { "query": "string" },
    "description": "Full-text search across the knowledge base"
  },
  {
    "name": "view",
    "params": { "path": "string" },
    "description": "Read content from a specific file path"
  }
]

```

### Invoke a Specific Tool

After parsing the list, call the target tool by referencing its exact name from the discovery response:

```bash
curl -sS -X POST https://your-knowledge-service/v3/tools/call \
     -H "Content-Type: application/json" \
     -d '{
           "tool_name": "search",
           "params": { "query": "memory hub architecture" }
         }'

```

This pattern appears in the repository documentation at [`README.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/README.md) (lines 265-267), which states that agents "first discover capabilities via `/v3/tools/list`, then use `/v3/tools/call` to read relevant pages, source code, or impact paths."

## Implementing Tool Discovery in TypeScript

For production agents, the TypeScript SDK abstracts the HTTP layer into typed methods. The core client implementation resides in the MemoryCore package, wrapping the same endpoints described in [`MemoryKnowledge/src/routes/tools.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/routes/tools.ts).

### Initialize the Knowledge Client

```typescript
import { KnowledgeClient } from '@tencentdb/memory-core';

const client = new KnowledgeClient({
  baseURL: 'https://your-knowledge-service/v3'
});

```

### List and Call Tools Programmatically

```typescript
// List available tools for the agent
const tools = await client.listTools();
console.log('Available tools:', tools);

// Execute the search tool
const result = await client.callTool('search', {
  query: 'database migration patterns'
});

```

The SDK handles serialization, error handling, and type validation against the schemas returned by the discovery endpoint.

## Agent-Side Prompt Injection

The **MemoryProxy** component automates tool discovery for LLM agents by injecting static instructions directly into the system prompt. Located in [`MemoryProxy/src/injection/injectors/knowledge-tools-injector.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/injection/injectors/knowledge-tools-injector.ts) (lines 4-8 and 78-86), this injector renders a `<tdai_memory_tools>` XML block containing curl recipes for both endpoints.

When an agent processes its system prompt, it encounters this block:

```text
<tdai_memory_tools>
POST /v3/tools/list   # discover tools

POST /v3/tools/call   # invoke a tool, payload: {"tool_name":"...","params":{...}}

</tdai_memory_tools>

```

This injection technique eliminates the need for manual endpoint configuration. The LLM parses the block and generates the appropriate `curl` commands to list available tools dynamically, adhering to the exact specifications defined in [`MemoryKnowledge/src/routes/tools.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/routes/tools.ts).

## Summary

- **Discovery Endpoint**: POST `/v3/tools/list` in [`MemoryKnowledge/src/routes/tools.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/routes/tools.ts) returns a JSON array of tool metadata.
- **Invocation Endpoint**: POST `/v3/tools/call` accepts `tool_name` and `params` to execute specific operations.
- **Manual Usage**: Use `curl` to list tools and invoke them by name against the knowledge service URL.
- **SDK Integration**: The TypeScript SDK provides `listTools()` and `callTool()` methods that mirror the REST API.
- **Automatic Injection**: `MemoryProxy` embeds curl recipes into LLM prompts via [`knowledge-tools-injector.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/knowledge-tools-injector.ts), enabling zero-configuration discovery.

## Frequently Asked Questions

### What format does the tools list endpoint return?

The `/v3/tools/list` endpoint returns a JSON array where each element contains the tool `name`, a `params` object defining required arguments, and a human-readable `description`. This structure allows agents to programmatically understand input requirements before attempting invocation.

### Can agents discover tools without using the HTTP API directly?

Yes. When using MemoryProxy, the system automatically injects a `<tdai_memory_tools>` block into the agent's prompt. This block contains pre-formatted curl commands for both listing and calling tools, allowing the LLM to self-discover capabilities without explicit HTTP client code, as implemented in [`MemoryProxy/src/injection/injectors/knowledge-tools-injector.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/injection/injectors/knowledge-tools-injector.ts).

### How does the system validate tool calls against the discovered list?

The invocation handler in [`MemoryKnowledge/src/routes/tools.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/routes/tools.ts) validates the `tool_name` field in the request body against the registry of tools returned by the discovery endpoint. If the requested tool does not exist in the list, the server returns a validation error before executing any logic.

### Where is the tool discovery pattern documented in the repository?

The primary documentation appears in the root [`README.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/README.md) (lines 265-267), which describes the two-step workflow: agents first call `/v3/tools/list` to enumerate capabilities, then target specific resources using `/v3/tools/call`. The implementation details are found in [`MemoryKnowledge/src/routes/tools.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/routes/tools.ts).