agentbay_knowledge_export
Export all knowledge for a project to onboard new agents, restore memory, or sync to local storage. Supports filters by source, type, and date.
Instructions
Export all knowledge for a project. Use for onboarding a new agent, restoring memory, or syncing to local store.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID | |
| source | No | Filter to entries from a specific agent | |
| types | No | ||
| since | No | ISO date — only entries updated after this timestamp | |
| includeDeprecated | No | Include deprecated entries (default false) |
Implementation Reference
- src/index.ts:809-835 (handler)The core implementation of the agentbay_knowledge_export tool. It registers an MCP tool with schema (projectId, source, types, since, includeDeprecated), builds query params, calls GET /api/v1/projects/{projectId}/knowledge/export, and formats the response as markdown text.
// Tool 26: Knowledge Export server.tool( 'agentbay_knowledge_export', 'Export all knowledge for a project. Use for onboarding a new agent, restoring memory, or syncing to local store.', { projectId: z.string().describe('Project ID'), source: z.string().optional().describe('Filter to entries from a specific agent'), types: z.array(z.enum(['PATTERN', 'PITFALL', 'ARCHITECTURE', 'DEPENDENCY', 'TEST_INSIGHT', 'PERFORMANCE', 'DECISION', 'CONTEXT'])).optional(), since: z.string().optional().describe('ISO date — only entries updated after this timestamp'), includeDeprecated: z.boolean().optional().describe('Include deprecated entries (default false)'), }, async ({ projectId, source, types, since, includeDeprecated }) => { const params = new URLSearchParams(); if (source) params.set('source', source); if (types?.length) params.set('types', types.join(',')); if (since) params.set('since', since); if (includeDeprecated) params.set('includeDeprecated', 'true'); const data = await apiGet(`/api/v1/projects/${projectId}/knowledge/export?${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 text = entries.map((k: any) => `### ${k.title} (${k.type})\nSource: ${k.source || 'unknown'} | Key: ${k.sourceRef || 'none'} | Confidence: ${k.confidence}\n${k.content}\n_Tags: ${k.tags?.join(', ') || 'none'} | Updated: ${k.updatedAt}_` ).join('\n\n---\n\n'); return { content: [{ type: 'text' as const, text: `Exported ${entries.length} entries from "${data.project?.name}":\n\n${text}` }] }; } ); - src/index.ts:810-819 (schema)Input schema for agentbay_knowledge_export: projectId (required string), source (optional string), types (optional enum array), since (optional ISO date string), includeDeprecated (optional boolean).
server.tool( 'agentbay_knowledge_export', 'Export all knowledge for a project. Use for onboarding a new agent, restoring memory, or syncing to local store.', { projectId: z.string().describe('Project ID'), source: z.string().optional().describe('Filter to entries from a specific agent'), types: z.array(z.enum(['PATTERN', 'PITFALL', 'ARCHITECTURE', 'DEPENDENCY', 'TEST_INSIGHT', 'PERFORMANCE', 'DECISION', 'CONTEXT'])).optional(), since: z.string().optional().describe('ISO date — only entries updated after this timestamp'), includeDeprecated: z.boolean().optional().describe('Include deprecated entries (default false)'), }, - src/index.ts:809-811 (registration)Registration of the 'agentbay_knowledge_export' tool on the MCP server via server.tool() call, binding the name, description, schema, and handler.
// Tool 26: Knowledge Export server.tool( 'agentbay_knowledge_export',