Update README for mcp.

This commit is contained in:
Hemang
2025-04-17 09:52:58 +02:00
parent 8a83133edf
commit 45d384b7a3
+44 -12
View File
@@ -1,7 +1,5 @@
This is a work in progress implementation for MCP (Model Context Protocol) with the Gateway.
This repository will be pushed to PyPi and then using it with the MCP config file will be simpler.
For now if the original MCP config file looks like:
```
@@ -20,11 +18,9 @@ For now if the original MCP config file looks like:
}
```
You need to:
## Using the PyPi package
1. Checkout the invariant-gatway repo.
2. Run `python -m build`. This will generate a .whl file in dist.
3. Modify the MCP config like this:
1. Modify the MCP config so that it looks like this:
```
{
@@ -32,18 +28,15 @@ You need to:
"weather": {
"command": "uvx",
"args": [
"--refresh",
"--from",
"/ABSOLUTE/PATH/TO/INVARIANT_GATEWAY_REPO/dist/invariant_gateway-0.0.1-py3-none-any.whl",
"run",
"invariant-gateway@latest",
"mcp",
"--project-name",
"weather-testing",
"<your-project-name>",
"--push-explorer",
"--exec",
"uv",
"--directory",
"/Users/hemang/Sdk/mcp/weather",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
"run",
"weather.py"
],
@@ -55,9 +48,48 @@ You need to:
}
```
Now Invariant MCP gateway will sit in between the MCP server and the MCP client and enforce the guardrails runtime. With this, you can also push the annotated traces for the MCP messages to explorer.
This moves the original `command` and `args` to the `args` list after the `--exec` flag.
All args before the `--exec` flag are relevant to the Invariant MCP gateway. These include:
- `--project-name`: With this you can specify the name of the Invariant Explorer project (dataset). The guardrails are pulled from this.
- `--push-explorer`: With this you can specify if you want to push the annotated traces to the Invariant Explorer. The annotated traces are pushed to the project name provided above.
## Local Development
You need to:
1. Checkout the invariant-gatway repo.
2. Run `python -m build`. This will generate a .whl file in dist.
3. Modify the MCP config so that it looks like this:
```
{
"mcpServers": {
"weather": {
"command": "uvx",
"args": [
"--refresh",
"--from",
"/ABSOLUTE/PATH/TO/INVARIANT_GATEWAY_REPO/dist/invariant_gateway-<VERSION>-py3-none-any.whl",
"invariant-gateway",
"mcp",
"--project-name",
"<your-project-name>",
"--push-explorer",
"--exec",
"uv",
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
"run",
"weather.py"
],
"env": {
"INVARIANT_API_KEY": "<Add Invariant API key here>"
}
}
}
}
```