coderswap_list_projects
Retrieve all available CoderSwap projects accessible with your API key to manage and work with existing knowledge bases.
Instructions
List all CoderSwap projects available to your API key
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/index.ts:253-311 (handler)Executes the tool logic: fetches projects via client.listProjects(), formats output and response with structured content.async () => { try { log('debug', 'Listing projects') const projects = await client.listProjects() const output = { count: projects.length, projects: projects.map(p => ({ project_id: p.project_id, name: p.name, doc_count: p.doc_count, search_mode: (p as any).search_mode })) } if (projects.length === 0) { return { content: [{ type: 'text', text: 'No projects found' }], structuredContent: output } } const projectList = projects .map(p => { const lines = [ `• ${p.name || 'Untitled Project'}`, ` ID: ${p.project_id}`, ` Docs: ${p.doc_count ?? 0}` ] if ((p as any).search_mode) { lines.push(` Search Mode: ${(p as any).search_mode}`) } return lines.join('\n') }) .join('\n\n') log('info', `Found ${projects.length} projects`) return { content: [{ type: 'text', text: `Found ${projects.length} project(s):\n\n${projectList}` }], structuredContent: output } } catch (error) { log('error', 'Failed to list projects', { error: error instanceof Error ? error.message : error }) return { content: [{ type: 'text', text: `✗ Failed to list projects: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true } } }
- src/index.ts:240-252 (schema)Zod schemas for input (empty) and output of the tool.{ title: 'List CoderSwap Projects', description: 'List all CoderSwap projects available to your API key', inputSchema: {}, outputSchema: { count: z.number(), projects: z.array(z.object({ project_id: z.string(), name: z.string().optional(), doc_count: z.number().optional() })) } },
- src/index.ts:238-312 (registration)Registers the 'coderswap_list_projects' tool on the MCP server with schema and handler function.server.registerTool( 'coderswap_list_projects', { title: 'List CoderSwap Projects', description: 'List all CoderSwap projects available to your API key', inputSchema: {}, outputSchema: { count: z.number(), projects: z.array(z.object({ project_id: z.string(), name: z.string().optional(), doc_count: z.number().optional() })) } }, async () => { try { log('debug', 'Listing projects') const projects = await client.listProjects() const output = { count: projects.length, projects: projects.map(p => ({ project_id: p.project_id, name: p.name, doc_count: p.doc_count, search_mode: (p as any).search_mode })) } if (projects.length === 0) { return { content: [{ type: 'text', text: 'No projects found' }], structuredContent: output } } const projectList = projects .map(p => { const lines = [ `• ${p.name || 'Untitled Project'}`, ` ID: ${p.project_id}`, ` Docs: ${p.doc_count ?? 0}` ] if ((p as any).search_mode) { lines.push(` Search Mode: ${(p as any).search_mode}`) } return lines.join('\n') }) .join('\n\n') log('info', `Found ${projects.length} projects`) return { content: [{ type: 'text', text: `Found ${projects.length} project(s):\n\n${projectList}` }], structuredContent: output } } catch (error) { log('error', 'Failed to list projects', { error: error instanceof Error ? error.message : error }) return { content: [{ type: 'text', text: `✗ Failed to list projects: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true } } } )
- src/coderswap-client.ts:89-95 (helper)API client method that fetches the list of projects from the CoderSwap backend.async listProjects(): Promise<ProjectSummary[]> { const res = await fetch(`${this.baseUrl}/v1/projects`, { headers: this.headers }) const data = await this.handleResponse<{ projects: ProjectSummary } | { projects: ProjectSummary[] }>(res) return Array.isArray((data as any).projects) ? (data as any).projects : [] }