An Model Context Protocol (MCP) prototype for Semarchy xDM.
MCP is a protocol for connecting large language models (LLMs) to external data sources, allowing LLMs to retrieve and manipulate data in real time. This project provides a prototype MCP server that connects to Semarchy xDM, allowing LLMs to access and manipulate data in Semarchy xDM.
//TODO: Test the setup steps from the source code.
Requirements:
- Python 3.11 and above.
uvpackage manager. Usebrew install uvto install on MacOS.
To setup the project:
- Unzip the
semarchy-mcp.ziparchive to a folder. - Open a terminal this folder.
- Run the following commands to create the virtual environment:
# Create the Python virtual environment uv venv # Activate the virtual environment source .venv/bin/activate # Install the dependencies uv sync
You do not need to run the MCP server. The client will run the server.
The MCP inspector is a tool provided by Anthropic to test the various endpoints exposed by an MCP Server, exposing a web interface to test the various endpoints.
It is not required to run the MCP server, but it is a good way to test the server and see how it behaves.
npx @modelcontextprotocol/inspector uv --directory <your project folder>/semarchy-mcp run --env-file .env mcp-server.pyNote that:
- You should replace in the command
<your project folder>with the folder containing the mcp-server code. - You should create a
.envfile in the folder of the mcp-server, to give the xDM connection configuration. This file is referenced in the command above, and an example is provided below.
# .env file for MCP Server
# xDM Configuration
XDM_BASE_URL=http://localhost:8088/semarchy
XDM_USERNAME=semadmin
XDM_PASSWORD=xxxxxx
# The API key supercdes the user/password authentication if both are provided.
XDM_API_KEY=xxxxxxxxx
# Default xDM data location: This is the location that will be used if no data location is specified in the request.
XDM_DATA_LOCATION=ProductRetailDemoClaude Desktop provides support for MCP server.
- Install Claude Desktop from Anthropic.
- Open the app and login.
- Edit the Claude Desktop Configuration file in
~/Library/Application Support/Claude/claude_desktop_config.jsonand add the following code. Make sure to update:<your project folder>with folder into which the semarchy-mcp project is installed- the various pieces in the
envsection with your xDM connection information.{ "mcpServers": { "Semarchy DM": { "command": "uv", "args": [ "--directory", "<your project folder>/semarchy-mcp", "run", "mcp-server.py" ], "env": { "XDM_BASE_URL": "http://localhost:8088/semarchy", "XDM_USERNAME": "<user name>", "XDM_PASSWORD": "<user password>", "XDM_API_KEY": "<api key, supercedes user/password authentication>" } } } }
- Restart Claude Desktop.
- Enter a prompt, such as:
- Return the top 10 customers in CustomerB2CDemo
- Continue the conversation with more complex requests, such as:
- Can you tell how many of these customers are female?
- Can you return all fields for Antonia Mattos and Toni Mattos and put them side by side so that I can compare them?
NOTE: Claude used Anthropic's models, which have a daily limit with a free account.
- Implement a dedicated Chat Agent with a Chainlit interface, removing the need for Claude Desktop and allowing the choice of the LLM.
- Implement error management in tools for the LLM to report meaningful errors to the user.
- Implement additional MCP endpoints to support more complex use cases.
- Convert the APIs to MCP endpoints.
This section is for contributors to the MCP server project, or developers desiring to start a new MCP server project.
This section describes the original setup of the MCP server project. It is given here for reference only, should you want to recreate a project from scratch.
uv init semarchy-mcp
cd semarchy-mcpuv venv
source .venv/bin/activateuv add "mcp[cli]" httpx requests