MCP server in Analytica

New in Analytica 7.0

The feature described here is experimental and for the time being intended for Lumina-internal use. As an experimental feature, it is subject to change.

Implementing an MCP server

A Model Context Protocol (MCP) server exposes tools that can be used by an AI agent such as Claude Code and Gemini CLI. It is possible to implement an MCP server directly in an Analytica model using specially tagged UDFs to implement each tool. It is easy to do so, and can enable AI agents to use or control your Analytica model.

At present, this feature has been created and is being used (or use being explored) internally at Lumina in several ways, including:

  • For automation of Quality Assurance testing.
  • For end-to-end Assista evaluation (especially when Assista takes actions during its response).
  • To enable AI coding tools to more actively control Analytica when developing code, debugging, reproducing UI bugs, etc.
  • To interactively use desktop Analytica in coordination with Claude Code, especially on some cases where Claude has access to tools that Assista does not.

The current feature implementation has distinct limitations, and is likely to change as we gain more internal experience with coordinating AI agents and desktop Analytica.

Creating an MCP server

To put desktop Analytica into an MCP-serving mode, you need to launch it with the command line parameter:

Analytica.exe /mcp:«port»

such as

Analytica.exe /mcp:6541

To implement a tool that an AI agent can use, create a User-Defined Function with a description that guides a language model as to when and how to use the tool, and then include the following text somewhere within the description: {@mcpTool}. We usually place this at the very beginning or very end of the description. This tag labels the UDF as an MCP tool.

When you declare parameters, you must declare the data type of each parameter as either Number or Text. The atom qualifier is also recommended but not required. Parameters can be optional and can include default values. At this time, no parameter can be declared as an array, index, object (or other non-evaluated eval mode), or repeated parameter. These may be relaxed later as the implementation becomes more complete.

If your UDF makes use of parameter qualifiers that are not yet supported, it will not be included in the tool/list result.

Configuring the client

To configure the client to use your server, your Analytica process must already be running with your UDFs existing.

Configure the client using a Transport type of "Streamable HTTP" and a URL of "http://localhost:6541/mcp", where the port number matches the port you used for the /mcp:6541 parameter when you launched Analytica.exe.

A convenient testing client is the MCP Inspector which can be run in an installation-free mode. You do have to already have Node.js installed, and then from a command line just run:

npx @modelcontextprotocol/inspector

The testing client UI opens in a browser. After you connect, you should see your exposed UDFs after pressing List tools.

Limitations

There are currently many limitations. These contribute to the experimental status of the feature. These may be progressively relaxed in the future.

  • Not namespace aware - make sure your tools are in scope from the main model and names not ambiguous.
  • Only a subset of Function Parameter Qualifiers currently supported:
    • Only Number and Text parameters
    • Array parameters, index parameters, and other evaluation models other than Context are not supported.
    • Repeated parameters not supported.
  • No array abstraction on calls.
  • Can only be used by AI agents running on localhost.
  • Does not proactively push notification to clients when changes to the tools/list occur. (But you can interactively debug and refine your tools, you clients just need to re-read the tool list. Claude Code needs to be restarted to have in reread).
  • There is no authentication on the connection. Hence, once you have your server running, and process running on localhost could potentially connect and call your tools.
Comments


You are not allowed to post comments.