coderswap_get_project_stats
Retrieve statistics and detailed information about a specific project to track progress and analyze project data.
Instructions
Get statistics and information about a specific project
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes |
Input Schema (JSON Schema)
{
"properties": {
"project_id": {
"minLength": 1,
"type": "string"
}
},
"required": [
"project_id"
],
"type": "object"
}
Implementation Reference
- src/index.ts:330-361 (handler)The handler function that executes the 'coderswap_get_project_stats' tool logic. It fetches stats using the CoderSwapClient, formats a textual summary and structured output.async ({ project_id }) => { try { log('debug', 'Getting project stats', { project_id }) const stats = await client.getProjectStats(project_id) const output = { project_id: stats.project_id, name: stats.name, doc_count: stats.doc_count, created_at: stats.created_at } log('info', `Retrieved stats for project: ${project_id}`) return { content: [{ type: 'text', text: `Project: ${stats.name || project_id}\nDocuments: ${stats.doc_count || 0}\nCreated: ${stats.created_at || 'Unknown'}` }], structuredContent: output } } catch (error) { log('error', 'Failed to get project stats', { project_id, error: error instanceof Error ? error.message : error }) return { content: [{ type: 'text', text: `✗ Failed to get project stats: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true } } }
- src/index.ts:317-329 (schema)Input and output schema definitions (Zod) for the 'coderswap_get_project_stats' tool, defining validation for project_id input and expected stats output.{ title: 'Get CoderSwap Project Stats', description: 'Get statistics and information about a specific project', inputSchema: { project_id: z.string().min(1, 'project_id is required') }, outputSchema: { project_id: z.string(), name: z.string().optional(), doc_count: z.number().optional(), created_at: z.string().optional() } },
- src/index.ts:316-362 (registration)The server.registerTool call that registers the 'coderswap_get_project_stats' tool with the MCP server, including schema and handler.'coderswap_get_project_stats', { title: 'Get CoderSwap Project Stats', description: 'Get statistics and information about a specific project', inputSchema: { project_id: z.string().min(1, 'project_id is required') }, outputSchema: { project_id: z.string(), name: z.string().optional(), doc_count: z.number().optional(), created_at: z.string().optional() } }, async ({ project_id }) => { try { log('debug', 'Getting project stats', { project_id }) const stats = await client.getProjectStats(project_id) const output = { project_id: stats.project_id, name: stats.name, doc_count: stats.doc_count, created_at: stats.created_at } log('info', `Retrieved stats for project: ${project_id}`) return { content: [{ type: 'text', text: `Project: ${stats.name || project_id}\nDocuments: ${stats.doc_count || 0}\nCreated: ${stats.created_at || 'Unknown'}` }], structuredContent: output } } catch (error) { log('error', 'Failed to get project stats', { project_id, error: error instanceof Error ? error.message : error }) return { content: [{ type: 'text', text: `✗ Failed to get project stats: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true } } } )
- src/coderswap-client.ts:97-104 (helper)Supporting method in CoderSwapClient that implements the core logic for retrieving project stats by filtering from the list of projects.async getProjectStats(projectId: string) { const projects = await this.listProjects() const project = projects.find((item) => item.project_id === projectId) if (!project) { throw new Error(`Project ${projectId} not found`) } return project }
- src/types.ts:30-32 (schema)Zod schema for project stats input (project_id), defined in types file (though inline schema used in tool).export const projectStatsSchema = z.object({ project_id: z.string().min(1) })