agentbay_knowledge_query
Search project knowledge to uncover patterns, pitfalls, and learnings. Use semantic queries to retrieve insights across projects, teams, or all scopes, filtered by type and tags.
Instructions
Search project knowledge for patterns, pitfalls, and learnings. Supports semantic search.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID | |
| query | No | Search query | |
| type | No | ||
| tags | No | ||
| scope | No | ||
| limit | No |
Implementation Reference
- src/index.ts:310-328 (handler)The handler function for the 'agentbay_knowledge_query' tool. Builds query parameters from optional inputs (query, type, tags, scope, limit), sends a GET request to the knowledge API endpoint, and formats the response showing knowledge entries with similarity scores, confidence, and tags.
async ({ projectId, query, type, tags, scope, limit }) => { const params = new URLSearchParams(); if (query) params.set('q', query); if (type) params.set('type', type); if (tags?.length) params.set('tags', tags.join(',')); if (scope) params.set('scope', scope); if (limit) params.set('limit', String(limit)); const data = await apiGet(`/api/v1/projects/${projectId}/knowledge?${params.toString()}`); if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] }; const entries = data.knowledge || []; if (!entries.length) return { content: [{ type: 'text' as const, text: 'No knowledge entries found.' }] }; const searchMode = data.searchMode ? ` | Search: ${data.searchMode}` : ''; const text = entries.map((k: any) => { const sim = k.similarityScore ? ` | Similarity: ${(k.similarityScore * 100).toFixed(0)}%` : ''; return `### ${k.title} (${k.type})\nID: ${k.id}\n${k.content}\n_Confidence: ${k.confidence} | Tags: ${k.tags?.join(', ') || 'none'}${sim}_`; }).join('\n\n'); return { content: [{ type: 'text' as const, text: `Knowledge (${entries.length}${searchMode}):\n\n${text}` }] }; } ); - src/index.ts:302-309 (schema)Zod schema defining input parameters: projectId (required string), query (optional string), type (optional enum of knowledge types), tags (optional string array), scope (optional 'project'|'team'|'all'), and limit (optional number).
{ projectId: z.string().describe('Project ID'), query: z.string().optional().describe('Search query'), type: z.enum(['PATTERN', 'PITFALL', 'ARCHITECTURE', 'DEPENDENCY', 'TEST_INSIGHT', 'PERFORMANCE', 'DECISION', 'CONTEXT']).optional(), tags: z.array(z.string()).optional(), scope: z.enum(['project', 'team', 'all']).optional(), limit: z.number().optional(), }, - src/index.ts:299-328 (registration)Registration of the 'agentbay_knowledge_query' tool via server.tool() with description 'Search project knowledge for patterns, pitfalls, and learnings. Supports semantic search.'
server.tool( 'agentbay_knowledge_query', 'Search project knowledge for patterns, pitfalls, and learnings. Supports semantic search.', { projectId: z.string().describe('Project ID'), query: z.string().optional().describe('Search query'), type: z.enum(['PATTERN', 'PITFALL', 'ARCHITECTURE', 'DEPENDENCY', 'TEST_INSIGHT', 'PERFORMANCE', 'DECISION', 'CONTEXT']).optional(), tags: z.array(z.string()).optional(), scope: z.enum(['project', 'team', 'all']).optional(), limit: z.number().optional(), }, async ({ projectId, query, type, tags, scope, limit }) => { const params = new URLSearchParams(); if (query) params.set('q', query); if (type) params.set('type', type); if (tags?.length) params.set('tags', tags.join(',')); if (scope) params.set('scope', scope); if (limit) params.set('limit', String(limit)); const data = await apiGet(`/api/v1/projects/${projectId}/knowledge?${params.toString()}`); if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] }; const entries = data.knowledge || []; if (!entries.length) return { content: [{ type: 'text' as const, text: 'No knowledge entries found.' }] }; const searchMode = data.searchMode ? ` | Search: ${data.searchMode}` : ''; const text = entries.map((k: any) => { const sim = k.similarityScore ? ` | Similarity: ${(k.similarityScore * 100).toFixed(0)}%` : ''; return `### ${k.title} (${k.type})\nID: ${k.id}\n${k.content}\n_Confidence: ${k.confidence} | Tags: ${k.tags?.join(', ') || 'none'}${sim}_`; }).join('\n\n'); return { content: [{ type: 'text' as const, text: `Knowledge (${entries.length}${searchMode}):\n\n${text}` }] }; } );