fund.knoewledge
Search and retrieve financial fund information from a knowledge base using keywords, enabling users to query fund data through natural language.
Instructions
获取的知识库列表信息
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "fund.knoewledge"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kw | No | 关键词,支持模糊查询 | |
| pageSize | No | 每页数量,默认10 | |
| pageNum | No | 页码,默认1 |
Implementation Reference
- tool-handlers/index.ts:24-57 (handler)The core handler function for the 'fund.knoewledge' tool. Parses input args, constructs API URL with query params, fetches from KB_API_URL, and returns the JSON response as standardized content.
async function handleKnowledge(args: unknown) { const { kw = "", pageSize = 10, pageNum = 1 } = knowledgeSchema.parse(args); const url = new URL(KB_API_URL); url.searchParams.set("kw", kw); url.searchParams.set("pageSize", String(pageSize)); url.searchParams.set("pageNum", String(pageNum)); const response = await fetch(url.toString(), { method: "GET", headers: { Accept: "application/json", }, }); if (!response.ok) { throw new Error( `Knowledge API request failed: ${response.status} ${response.statusText}` ); } let data: any; try { data = await response.json(); } catch (e) { throw new Error("Knowledge API returned invalid JSON"); } // Normalize basic shape: { code, msg, result } console.log('handleKnowledge', data) return { content: [{ type: "text", text: JSON.stringify(data) }], }; } - tool-handlers/index.ts:7-11 (schema)Zod schema used in the handler to validate and parse input parameters for the knowledge query (kw, pageSize, pageNum).
const knowledgeSchema = z.object({ kw: z.string().optional().default(""), pageSize: z.number().int().positive().optional(), pageNum: z.number().int().positive().optional(), }); - tool-registry/index.ts:13-24 (registration)Tool registration entry in getAllTools() array, defining name, description, and input schema for MCP tool discovery.
{ name: 'fund.knoewledge', description: '获取的知识库列表信息', inputSchema: { type: 'object', properties: { kw: { type: 'string', description: '关键词,支持模糊查询' }, pageSize: { type: 'number', description: '每页数量,默认10' }, pageNum: { type: 'number', description: '页码,默认1' } }, } }, - tool-handlers/index.ts:105-107 (handler)Dispatch logic in handleToolRequest that routes 'fund.knoewledge' calls to the handleKnowledge function.
if (name === "fund.knoewledge") { return await handleKnowledge(args); } - tool-handlers/index.ts:18-20 (helper)API endpoint URL configuration for the knowledge base query, with env var fallback.
const KB_API_URL = process.env.FUND_KB_API_URL || "https://reportdev.haiyu.datavita.com.cn/api/admin/knowledge/query"