Skip to content

Latest commit

 

History

History
77 lines (63 loc) · 3.99 KB

File metadata and controls

77 lines (63 loc) · 3.99 KB

Calling MCP Tools from Claude

The Claude® Desktop supports two types of MCP Servers:

  • STDIO: Local server that communicates via standard IO.
  • HTTP: Local or remote server that communicates via HTTP.

Both types of servers use the JSONRPC protocol, but STDIO servers must run on the same machine as the Claude Desktop while HTTP servers are more flexible and may run on any machine reachable via the network. MCP Framework for MATLAB Production Server builds HTTP servers. Some versions of Claude only support STDIO servers -- but the included STDIO to HTTP server bridge allows these versions to connect to HTTP servers.

This example demonstrates:

  • Coordination of multiple tools to produce the result requested by a user prompt.
  • An STDIO to HTTP bridge server that connects STDIO only hosts to HTTP MCP servers.

Periodic Noise Example

MCP hosts like Claude orchestrate the interaction of multiple MCP tools in response to a user prompt. Configure Claude with these tools:

  • cleanSignal, which removes periodic noise of a given frequency from an observed signal.
  • linePlot, which generates a simple line graph from a CSV file.
  • Filesystem extension, which allows Claude limited access to the file system.

cleanSignal is an HTTP server created by MCP Framework for MATLAB Production Server and hosted by MATLAB Production Server. linePlot is a STDIO server created with the FastMCP Python package.

Then issue this prompt:

Remove the 60Hz periodic noise from the signal in openloopVoltage.csv and generate a line graph of the result.

Claude will:

  1. Locate (and possibly examine) the openloopVoltage.csv file.
  2. Call the cleanSignal tool, passing it the location of openloopVoltage.csv and the name and location of an output file.
  3. Call the linePlot tool, passing it the full path to the filtered signal generated by cleanSignal and the name and location of an output file for the generated graph (a JPG file).
  4. Communicate the results -- in particular the name of the output signal and graph files.

Note that Claude manages the name and location of the tools' outputs itself -- the prompt does not specify or even mention them.

Setup

  1. Build and deploy the cleanSignal MCP tool as shown.
  2. Activate the File System extension in the Claude desktop app. In the Claude UI, click through Settings | Extensions | Browse Extensions and then select the Filesystem extension.
  3. Configure the Filesystem extension to allow access to at least one folder.
  4. Ensure the Python packages FastMCP and matplotlib are installed.
  5. Add the linePlot and cleanSignal MCP tools to your Claude configuration file.
  6. Restart Claude. Don't just close the desktop window -- quit the app and then restart it.

Claude Configuration File

Assumptions:

  • Python is available on your system path as the command "python".
  • The MCP Framwork (this package) installed in a folder named /work.
  • Log files should be written to /work/logs/mcp/claude.
  • The MATLAB Production Server hosting the MCP tools has the network address "http://localhost:9910". Modify the configuration file as necessary for your environment.
{
  "mcpServers": {
    "cleanSignal": {
      "command": "python",
      "args": [
	    "/work/mcp-framework-matlab-production-server/Utilities/mcpstdio2http.py", 
		"--log-level", "DEBUG",
		"--log-dir", "/work/logs/mcp/claude",
    "--url", "http://localhost:9910/cleanSignal/mcp",
		"--timeout", "300"
      ],
	  "networkTimeout": 600
    },
	"linePlot": {
      "command": "python",
      "args": [
	    "/work/mcp-framework-matlab-production-server/Utilities/linePlot.py", 
		"--log-level", "DEBUG",
		"--log-dir", ""/work/logs/mcp/claude"",
		"--timeout", "300"
      ],
	  "networkTimeout": 600
    }
  }
}