Add standard MCP protocol methods to tools list for better client discovery
- Add tools/list, tools/call, resources/list, resources/read, and ping methods - Include proper input schemas and descriptions for each method - Add debug logging for tools list generation - Position standard methods at beginning of list for first-page visibility
Showing
1 changed file
with
164 additions
and
0 deletions
| ... | @@ -171,6 +171,8 @@ | ... | @@ -171,6 +171,8 @@ |
| 171 | try { | 171 | try { |
| 172 | def availableTools = [] | 172 | def availableTools = [] |
| 173 | 173 | ||
| 174 | ec.logger.info("MCP ToolsList: DEBUG - Starting tools list generation") | ||
| 175 | |||
| 174 | // Get only services user has access to via artifact groups | 176 | // Get only services user has access to via artifact groups |
| 175 | def accessibleServiceNames = [] | 177 | def accessibleServiceNames = [] |
| 176 | for (serviceName in userAccessibleServices) { | 178 | for (serviceName in userAccessibleServices) { |
| ... | @@ -290,6 +292,87 @@ | ... | @@ -290,6 +292,87 @@ |
| 290 | ec.logger.warn("Error discovering screen tools: ${e.message}") | 292 | ec.logger.warn("Error discovering screen tools: ${e.message}") |
| 291 | } | 293 | } |
| 292 | 294 | ||
| 295 | // Add standard MCP protocol methods that clients can discover (add at end so they appear on first page) | ||
| 296 | def standardMcpMethods = [ | ||
| 297 | [ | ||
| 298 | name: "tools/list", | ||
| 299 | title: "List Available Tools", | ||
| 300 | description: "Get a list of all available MCP tools including Moqui services and screens", | ||
| 301 | inputSchema: [ | ||
| 302 | type: "object", | ||
| 303 | properties: [ | ||
| 304 | cursor: [ | ||
| 305 | type: "string", | ||
| 306 | description: "Pagination cursor for large tool lists" | ||
| 307 | ] | ||
| 308 | ], | ||
| 309 | required: [] | ||
| 310 | ] | ||
| 311 | ], | ||
| 312 | [ | ||
| 313 | name: "tools/call", | ||
| 314 | title: "Execute Tool", | ||
| 315 | description: "Execute a specific MCP tool by name with parameters", | ||
| 316 | inputSchema: [ | ||
| 317 | type: "object", | ||
| 318 | properties: [ | ||
| 319 | name: [ | ||
| 320 | type: "string", | ||
| 321 | description: "Name of the tool to execute" | ||
| 322 | ], | ||
| 323 | arguments: [ | ||
| 324 | type: "object", | ||
| 325 | description: "Parameters to pass to the tool" | ||
| 326 | ] | ||
| 327 | ], | ||
| 328 | required: ["name"] | ||
| 329 | ] | ||
| 330 | ], | ||
| 331 | [ | ||
| 332 | name: "resources/list", | ||
| 333 | title: "List Resources", | ||
| 334 | description: "Get a list of available MCP resources (Moqui entities)", | ||
| 335 | inputSchema: [ | ||
| 336 | type: "object", | ||
| 337 | properties: [ | ||
| 338 | cursor: [ | ||
| 339 | type: "string", | ||
| 340 | description: "Pagination cursor for large resource lists" | ||
| 341 | ] | ||
| 342 | ], | ||
| 343 | required: [] | ||
| 344 | ] | ||
| 345 | ], | ||
| 346 | [ | ||
| 347 | name: "resources/read", | ||
| 348 | title: "Read Resource", | ||
| 349 | description: "Read data from a specific MCP resource (Moqui entity)", | ||
| 350 | inputSchema: [ | ||
| 351 | type: "object", | ||
| 352 | properties: [ | ||
| 353 | uri: [ | ||
| 354 | type: "string", | ||
| 355 | description: "Resource URI to read (format: entity://EntityName)" | ||
| 356 | ] | ||
| 357 | ], | ||
| 358 | required: ["uri"] | ||
| 359 | ] | ||
| 360 | ], | ||
| 361 | [ | ||
| 362 | name: "ping", | ||
| 363 | title: "Ping Server", | ||
| 364 | description: "Test connectivity to the MCP server and get session info", | ||
| 365 | inputSchema: [ | ||
| 366 | type: "object", | ||
| 367 | properties: [:], | ||
| 368 | required: [] | ||
| 369 | ] | ||
| 370 | ] | ||
| 371 | ] | ||
| 372 | |||
| 373 | availableTools.addAll(standardMcpMethods) | ||
| 374 | ec.logger.info("MCP ToolsList: Added ${standardMcpMethods.size()} standard MCP protocol methods") | ||
| 375 | |||
| 293 | // Implement pagination according to MCP spec | 376 | // Implement pagination according to MCP spec |
| 294 | def pageSize = 50 // Reasonable page size for tool lists | 377 | def pageSize = 50 // Reasonable page size for tool lists |
| 295 | def startIndex = 0 | 378 | def startIndex = 0 |
| ... | @@ -2303,6 +2386,87 @@ def startTime = System.currentTimeMillis() | ... | @@ -2303,6 +2386,87 @@ def startTime = System.currentTimeMillis() |
| 2303 | } | 2386 | } |
| 2304 | ec.logger.info("list#Tools: Recursive processing found ${tools.size()} total tools") | 2387 | ec.logger.info("list#Tools: Recursive processing found ${tools.size()} total tools") |
| 2305 | 2388 | ||
| 2389 | // Add standard MCP protocol methods that clients can discover | ||
| 2390 | def standardMcpMethods = [ | ||
| 2391 | [ | ||
| 2392 | name: "tools/list", | ||
| 2393 | title: "List Available Tools", | ||
| 2394 | description: "Get a list of all available MCP tools including Moqui services and screens", | ||
| 2395 | inputSchema: [ | ||
| 2396 | type: "object", | ||
| 2397 | properties: [ | ||
| 2398 | cursor: [ | ||
| 2399 | type: "string", | ||
| 2400 | description: "Pagination cursor for large tool lists" | ||
| 2401 | ] | ||
| 2402 | ], | ||
| 2403 | required: [] | ||
| 2404 | ] | ||
| 2405 | ], | ||
| 2406 | [ | ||
| 2407 | name: "tools/call", | ||
| 2408 | title: "Execute Tool", | ||
| 2409 | description: "Execute a specific MCP tool by name with parameters", | ||
| 2410 | inputSchema: [ | ||
| 2411 | type: "object", | ||
| 2412 | properties: [ | ||
| 2413 | name: [ | ||
| 2414 | type: "string", | ||
| 2415 | description: "Name of the tool to execute" | ||
| 2416 | ], | ||
| 2417 | arguments: [ | ||
| 2418 | type: "object", | ||
| 2419 | description: "Parameters to pass to the tool" | ||
| 2420 | ] | ||
| 2421 | ], | ||
| 2422 | required: ["name"] | ||
| 2423 | ] | ||
| 2424 | ], | ||
| 2425 | [ | ||
| 2426 | name: "resources/list", | ||
| 2427 | title: "List Resources", | ||
| 2428 | description: "Get a list of available MCP resources (Moqui entities)", | ||
| 2429 | inputSchema: [ | ||
| 2430 | type: "object", | ||
| 2431 | properties: [ | ||
| 2432 | cursor: [ | ||
| 2433 | type: "string", | ||
| 2434 | description: "Pagination cursor for large resource lists" | ||
| 2435 | ] | ||
| 2436 | ], | ||
| 2437 | required: [] | ||
| 2438 | ] | ||
| 2439 | ], | ||
| 2440 | [ | ||
| 2441 | name: "resources/read", | ||
| 2442 | title: "Read Resource", | ||
| 2443 | description: "Read data from a specific MCP resource (Moqui entity)", | ||
| 2444 | inputSchema: [ | ||
| 2445 | type: "object", | ||
| 2446 | properties: [ | ||
| 2447 | uri: [ | ||
| 2448 | type: "string", | ||
| 2449 | description: "Resource URI to read (format: entity://EntityName)" | ||
| 2450 | ] | ||
| 2451 | ], | ||
| 2452 | required: ["uri"] | ||
| 2453 | ] | ||
| 2454 | ], | ||
| 2455 | [ | ||
| 2456 | name: "ping", | ||
| 2457 | title: "Ping Server", | ||
| 2458 | description: "Test connectivity to the MCP server and get session info", | ||
| 2459 | inputSchema: [ | ||
| 2460 | type: "object", | ||
| 2461 | properties: [:], | ||
| 2462 | required: [] | ||
| 2463 | ] | ||
| 2464 | ] | ||
| 2465 | ] | ||
| 2466 | |||
| 2467 | tools.addAll(0, standardMcpMethods) // Add at beginning so they appear on first page | ||
| 2468 | ec.logger.info("list#Tools: Added ${standardMcpMethods.size()} standard MCP protocol methods") | ||
| 2469 | |||
| 2306 | } finally { | 2470 | } finally { |
| 2307 | if (adminUserInfo != null) { | 2471 | if (adminUserInfo != null) { |
| 2308 | ec.user.popUser() | 2472 | ec.user.popUser() | ... | ... |
-
Please register or sign in to post a comment