Skip to main content
Glama
njlnaet
by njlnaet

coderswap_create_project

Create a new vector search project to build topic-specific knowledge bases for semantic search and research workflows.

Instructions

Create a new vector search project in CoderSwap

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
descriptionNo

Implementation Reference

  • MCP tool handler function that calls CoderSwapClient.createProject, processes the response, and returns formatted success/error output.
    async ({ name, description }) => {
      try {
        log('debug', 'Creating project', { name, description })
        const project: any = await client.createProject({ name, description })
    
        const output = {
          project_id: project.project_id,
          name: project.name || name,
          status: project.status
        }
    
        log('info', `Created project: ${project.project_id}`)
    
        return {
          content: [{
            type: 'text',
            text: `✓ Created project "${name}" (ID: ${project.project_id})`
          }],
          structuredContent: output
        }
      } catch (error) {
        log('error', 'Failed to create project', { error: error instanceof Error ? error.message : error })
        return {
          content: [{
            type: 'text',
            text: `✗ Failed to create project: ${error instanceof Error ? error.message : 'Unknown error'}`
          }],
          isError: true
        }
      }
    }
  • src/index.ts:190-235 (registration)
    Registration of the 'coderswap_create_project' tool with schema and inline handler function.
      'coderswap_create_project',
      {
        title: 'Create CoderSwap Project',
        description: 'Create a new vector search project in CoderSwap',
        inputSchema: {
          name: z.string().min(1, 'Project name is required'),
          description: z.string().optional()
        },
        outputSchema: {
          project_id: z.string(),
          name: z.string(),
          status: z.string().optional()
        }
      },
      async ({ name, description }) => {
        try {
          log('debug', 'Creating project', { name, description })
          const project: any = await client.createProject({ name, description })
    
          const output = {
            project_id: project.project_id,
            name: project.name || name,
            status: project.status
          }
    
          log('info', `Created project: ${project.project_id}`)
    
          return {
            content: [{
              type: 'text',
              text: `✓ Created project "${name}" (ID: ${project.project_id})`
            }],
            structuredContent: output
          }
        } catch (error) {
          log('error', 'Failed to create project', { error: error instanceof Error ? error.message : error })
          return {
            content: [{
              type: 'text',
              text: `✗ Failed to create project: ${error instanceof Error ? error.message : 'Unknown error'}`
            }],
            isError: true
          }
        }
      }
    )
  • Core helper method in CoderSwapClient that performs the HTTP POST request to create a project via the API, setting embedding_dim to 384.
    async createProject(input: CreateProjectInput) {
      const res = await fetch(`${this.baseUrl}/v1/projects`, {
        method: 'POST',
        headers: this.headers,
        body: JSON.stringify({
          name: input.name,
          description: input.description,
          embedding_dim: 384
        })
      })
      return this.handleResponse(res)
    }
  • Zod schema definition for CreateProjectInput used by the client and matching the tool's inputSchema.
    export const createProjectSchema = z.object({
      name: z.string().min(1, 'Project name is required'),
      description: z.string().optional()
    })

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