Model Context Protocol (MCP) is a protocol that enables Agents to connect to servers exposing Tools (specific functionalities).
Agents use these Tools to perform external actions in a controlled manner, such as accessing data, performing calculations, or interacting with systems.
Integrating MCP with GeneXus allows a Knowledge Base (KB) to automatically become an MCP Server, exposing its API objects as Tools without requiring additional development effort.
This integration enables you to:
-
Build Agents that leverage GeneXus business logic: Directly utilize the business logic defined in GeneXus within your Agents.
-
Easily configure Agent environments: Set up an environment where an Agent (using an AI Model such as Claude Desktop) can query and use GeneXus business functionality.
-
Enhance interoperability: Increase interoperability between the GeneXus ecosystem and various Agents.
This functionality allows you to expose methods defined in API objects as Tools within an MCP Server. Any Agent connected to the server can use these Tools to directly execute business tasks without requiring manual integrations.
You can control which API objects are exposed by configuring the Include in MCP Server property (set to False by default). The exposed methods appear as Tools in the MCP Server, and their descriptions are taken from the [Description] annotation to provide LLMs with the necessary context for execution.
The MCP Server is deployed with the Knowledge Base (KB) in Java using SpringBoot, listening on a URL that ends with /mcp. For example, in a local development environment, it might be http://localhost:8080/mcp. Agents with AI Models such as Claude Desktop can easily connect and execute operations defined in GeneXus through natural language prompts.
Suppose you define the following API object containing the methods you want to expose as Tools:
Client {
Description("Returns information for all clients in the system")
List(out:&SDTClients)
=> Core.ClientsList(&ClientCategoryCode, &SDTClients);
Description("Returns information for a client given a ClientID")
GetByKey(in:&ClientId, out:&Client, out:&Messages)
=> Core.ClientGetbyKey(&ClientId, &Client);
Description("Inserts a new client into the system")
RestMethod(POST)
Insert(in:&ClientId, in:&ClientName, in:&ClientAddress, out:&Messages)
=> Core.ClientInsert(&ClientId, &ClientName, &ClientAddress, &Messages);
Description("Updates a client in the system")
RestMethod(PUT)
Update(in:&ClientId, in:&ClientName, in:&ClientAddress, out:&Messages)
=> Core.ClientUpdate(&ClientId, &ClientName, &ClientAddress, &Messages);
}
It's crucial to provide clear and concise descriptions for each method you want to expose using the [Description] annotation. These descriptions will be used by the LLM to understand how to use the Tool.
To expose the methods in your API Object as Tools, you need to set the Include in MCP Server property to True.
When this property is set to True, GeneXus will automatically expose the methods in your API Object as Tools in the MCP Server. The name of each Tool will correspond to the method name, and the description will be taken from the [Description] annotation (if it exists). If no description is provided, only the method name will be used.
Deploy your KB to a Java environment with SpringBoot as you normally would. This deployment process makes the MCP Server accessible. Once the deployment is complete, take the following steps to connect your MCP Client (e.g., Claude Desktop):
If you want to expose different subsets of Tools, you can create multiple deployments. Each deployment will include only the API objects with the Include in MCP Server property set to True.
Generators: Java
Since GeneXus Next.