ac9f2945 by Ean Schuessler

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
1 parent 889b79ef
......@@ -171,6 +171,8 @@
try {
def availableTools = []
ec.logger.info("MCP ToolsList: DEBUG - Starting tools list generation")
// Get only services user has access to via artifact groups
def accessibleServiceNames = []
for (serviceName in userAccessibleServices) {
......@@ -290,6 +292,87 @@
ec.logger.warn("Error discovering screen tools: ${e.message}")
}
// Add standard MCP protocol methods that clients can discover (add at end so they appear on first page)
def standardMcpMethods = [
[
name: "tools/list",
title: "List Available Tools",
description: "Get a list of all available MCP tools including Moqui services and screens",
inputSchema: [
type: "object",
properties: [
cursor: [
type: "string",
description: "Pagination cursor for large tool lists"
]
],
required: []
]
],
[
name: "tools/call",
title: "Execute Tool",
description: "Execute a specific MCP tool by name with parameters",
inputSchema: [
type: "object",
properties: [
name: [
type: "string",
description: "Name of the tool to execute"
],
arguments: [
type: "object",
description: "Parameters to pass to the tool"
]
],
required: ["name"]
]
],
[
name: "resources/list",
title: "List Resources",
description: "Get a list of available MCP resources (Moqui entities)",
inputSchema: [
type: "object",
properties: [
cursor: [
type: "string",
description: "Pagination cursor for large resource lists"
]
],
required: []
]
],
[
name: "resources/read",
title: "Read Resource",
description: "Read data from a specific MCP resource (Moqui entity)",
inputSchema: [
type: "object",
properties: [
uri: [
type: "string",
description: "Resource URI to read (format: entity://EntityName)"
]
],
required: ["uri"]
]
],
[
name: "ping",
title: "Ping Server",
description: "Test connectivity to the MCP server and get session info",
inputSchema: [
type: "object",
properties: [:],
required: []
]
]
]
availableTools.addAll(standardMcpMethods)
ec.logger.info("MCP ToolsList: Added ${standardMcpMethods.size()} standard MCP protocol methods")
// Implement pagination according to MCP spec
def pageSize = 50 // Reasonable page size for tool lists
def startIndex = 0
......@@ -2303,6 +2386,87 @@ def startTime = System.currentTimeMillis()
}
ec.logger.info("list#Tools: Recursive processing found ${tools.size()} total tools")
// Add standard MCP protocol methods that clients can discover
def standardMcpMethods = [
[
name: "tools/list",
title: "List Available Tools",
description: "Get a list of all available MCP tools including Moqui services and screens",
inputSchema: [
type: "object",
properties: [
cursor: [
type: "string",
description: "Pagination cursor for large tool lists"
]
],
required: []
]
],
[
name: "tools/call",
title: "Execute Tool",
description: "Execute a specific MCP tool by name with parameters",
inputSchema: [
type: "object",
properties: [
name: [
type: "string",
description: "Name of the tool to execute"
],
arguments: [
type: "object",
description: "Parameters to pass to the tool"
]
],
required: ["name"]
]
],
[
name: "resources/list",
title: "List Resources",
description: "Get a list of available MCP resources (Moqui entities)",
inputSchema: [
type: "object",
properties: [
cursor: [
type: "string",
description: "Pagination cursor for large resource lists"
]
],
required: []
]
],
[
name: "resources/read",
title: "Read Resource",
description: "Read data from a specific MCP resource (Moqui entity)",
inputSchema: [
type: "object",
properties: [
uri: [
type: "string",
description: "Resource URI to read (format: entity://EntityName)"
]
],
required: ["uri"]
]
],
[
name: "ping",
title: "Ping Server",
description: "Test connectivity to the MCP server and get session info",
inputSchema: [
type: "object",
properties: [:],
required: []
]
]
]
tools.addAll(0, standardMcpMethods) // Add at beginning so they appear on first page
ec.logger.info("list#Tools: Added ${standardMcpMethods.size()} standard MCP protocol methods")
} finally {
if (adminUserInfo != null) {
ec.user.popUser()
......