@@ -30,6 +30,7 @@ export class McpGenerator {
3030 moduleSpecifier : "@modelcontextprotocol/sdk/server/sse.js" ,
3131 namedImports : [ "SSEServerTransport" ] ,
3232 } ) ;
33+ mcpFile . addStatements ( "// @ts-ignore" ) ;
3334 mcpFile . addImportDeclaration ( {
3435 moduleSpecifier : "express" ,
3536 defaultImport : "express" ,
@@ -56,7 +57,7 @@ export function createMcpServer() {
5657 'openapi_spec',
5758 'openapi://spec',
5859 { mimeType: 'application/json', description: 'The complete OpenAPI specification' },
59- async (uri) => ({
60+ async (uri: URL ) => ({
6061 contents: [{
6162 uri: uri.href,
6263 mimeType: 'application/json',
@@ -85,13 +86,16 @@ export function createMcpServer() {
8586` ;
8687
8788 for ( const op of parser . operations ) {
88- const group = op . tags ?. [ 0 ]
89+ const groupName = op . tags ?. [ 0 ]
8990 ? typeof op . tags [ 0 ] === "string"
9091 ? op . tags [ 0 ]
9192 : ( op . tags [ 0 ] as object as { name ?: string } ) . name ||
9293 String ( op . tags [ 0 ] )
9394 : "Default" ;
94- const serviceName = `${ group } Service` ;
95+ const groupPascal = String ( groupName ) . replace ( / ( ^ \w | - \w ) / g, ( m ) =>
96+ m . replace ( "-" , "" ) . toUpperCase ( ) ,
97+ ) ;
98+ const serviceName = `${ groupPascal } Client` ;
9599 const methodName =
96100 op . operationId || op . path . replace ( / \/ / g, "_" ) . replace ( / ^ _ / , "" ) ;
97101 const toolName = snakeCase ( methodName ) ;
@@ -100,9 +104,9 @@ export function createMcpServer() {
100104 statements += `
101105 server.resource(
102106 'openapi_operation_${ toolName } ',
103- new ResourceTemplate('openapi://operations/${ toolName } '),
104- { mimeType: 'application/json', description: 'Operation details for ${ toolName } ', annotations: { audience: ["developer "], priority: 0 } },
105- async (uri) => ({
107+ new ResourceTemplate('openapi://operations/${ toolName } ', { listCallback: undefined } ),
108+ { mimeType: 'application/json', description: 'Operation details for ${ toolName } ', annotations: { audience: ["user "], priority: 0 } },
109+ async (uri: URL ) => ({
106110 contents: [{
107111 uri: uri.href,
108112 mimeType: 'application/json',
@@ -165,12 +169,12 @@ export function serveMcpSse(port = 3001) {
165169 const server = createMcpServer();
166170 let transport: SSEServerTransport;
167171
168- app.get("/mcp/sse", async (req, res) => {
172+ app.get("/mcp/sse", async (req: any , res: any ) => {
169173 transport = new SSEServerTransport("/mcp/messages", res);
170174 await server.connect(transport);
171175 });
172176
173- app.post("/mcp/messages", async (req, res) => {
177+ app.post("/mcp/messages", async (req: any , res: any ) => {
174178 if (transport) {
175179 await transport.handlePostMessage(req, res);
176180 } else {
@@ -242,11 +246,7 @@ export class McpClient {
242246 },
243247 {
244248 capabilities: {
245- tools: {},
246- prompts: {},
247- resources: { subscribe: true },
248249 roots: { listChanged: true },
249- sampling: {},
250250 experimental: {}
251251 },
252252 }
@@ -284,7 +284,7 @@ export class McpClient {
284284 await this.client.ping();
285285 }
286286
287- async executeTool(name: string, args: Record<string, any>): Promise<CallToolResult> {
287+ async executeTool(name: string, args: Record<string, any>) {
288288 return await this.client.callTool({
289289 name,
290290 arguments: args
@@ -334,7 +334,7 @@ export class McpClient {
334334 }
335335
336336 async setLoggingLevel(level: any): Promise<void> {
337- await this.client.setLoggingLevel({ level } );
337+ await this.client.setLoggingLevel(level);
338338 }
339339
340340 async sendRootsListChanged(): Promise<void> {
@@ -398,13 +398,16 @@ export class McpClient {
398398 switch (name) {` ;
399399
400400 for ( const op of parser . operations ) {
401- const group = op . tags ?. [ 0 ]
401+ const groupName = op . tags ?. [ 0 ]
402402 ? typeof op . tags [ 0 ] === "string"
403403 ? op . tags [ 0 ]
404404 : ( op . tags [ 0 ] as object as { name ?: string } ) . name ||
405405 String ( op . tags [ 0 ] )
406406 : "Default" ;
407- const serviceName = `${ group } Service` ;
407+ const groupPascal = String ( groupName ) . replace ( / ( ^ \w | - \w ) / g, ( m ) =>
408+ m . replace ( "-" , "" ) . toUpperCase ( ) ,
409+ ) ;
410+ const serviceName = `${ groupPascal } Client` ;
408411 const methodName =
409412 op . operationId || op . path . replace ( / \/ / g, "_" ) . replace ( / ^ _ / , "" ) ;
410413 const toolName = snakeCase ( methodName ) ;
0 commit comments