Skip to main content
Glama
njlnaet
by njlnaet

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

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes

Implementation Reference

  • 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
        }
      }
    }
  • 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
          }
        }
      }
    )
  • 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
    }
  • 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)
    })

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/njlnaet/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server