@kubb/plugin-mcp
Version:
Generator mcp
47 lines (40 loc) • 1.5 kB
text/typescript
/**
* Generated by Kubb (https://kubb.dev/).
* Do not edit manually.
*/
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp'
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio'
import { listPetsHandler, listPetsQueryParams, createPetsHandler, createPetsMutationRequest, showPetByIdHandler, showPetByIdPathParams } from './showPetById'
export const server = new McpServer({
name: 'Swagger Petstore',
version: '3.0.0',
})
server.tool('listPets', 'Returns all `pets` from the system \\n that the user has access to', { params: listPetsQueryParams }, async ({ params }) => {
return listPetsHandler({ params })
})
server.tool(
'createPets',
'Creates a pet in the store.\nThis is an arbitrary description with lots of `strange` but likely formatting from the real world.\n- We like to make lists - And we need to escape: some, type, of `things`\n',
{ data: createPetsMutationRequest },
async ({ data }) => {
return createPetsHandler({ data })
},
)
server.tool(
'showPetById',
'Make a GET request to /pets/{petId}',
{ petId: showPetByIdPathParams.shape['petId'], testId: showPetByIdPathParams.shape['testId'] },
async ({ petId, testId }) => {
return showPetByIdHandler({ petId, testId })
},
)
async function startServer() {
try {
const transport = new StdioServerTransport()
await server.connect(transport)
} catch (error) {
console.error('Failed to start server:', error)
process.exit(1)
}
}
startServer()