Skip to content

Commit 3a719c5

Browse files
authored
feat(cluster): add MCP server to work with Platform (#218)
* feat(cluster): add MCP server to work with Platform * refactor(mcp): inject client into mcp context * refactor(mcp): use MCP to try and get around logging issues * refactor(mcp): move cluster health into tool * fix(MCP): use getattr not getitem to access client * feat(MCP): add bot info resource, and start/stop bot * fix(MCP): Catch ImportError for mcp usage * feat(MCP): add more resources; add docs to existing tools/resources * refactor(MCP): temporarily use tools instead of resources for stuff * feat(MCP): add instructions; bot logs tool * refactor(MCP): make MCP cluster-only, remove platform tools, add config * feat(MCP): add variable group resources * refactor(MCP): explicitly declare sse transport only * feat(MCP): add a prompt for looking at cluster health * refactor(MCP): change server name slightly * feat(MCP): add `new_bot` and `remove_bot` tools * docs(MCP): add notes to code why vargroups are not allowed C-UD methods * docs(MCP): add some other docs behind design decisions * feat(MCP): add `update_bot` tool * refactor(MCP): only import mcp server if command is called * refactor(CLI): hide display so that MCP server works w/ stdio transport * refactor(MCP): update to using `fastmcp` because `mcp` module sucks * refactor(MCP): drop resources, not a good fit * feat(MCP): add tool to fetch URL of connected cluster * refactor(MCP): show full bot log entry to see timestamps * docs(MCP): add documentation for MCP CLI command & Cluster userguide * style(CLI): fix line too long * fix(Typing): forgot to install mcp extra for type checking
1 parent 36f279b commit 3a719c5

File tree

7 files changed

+415
-135
lines changed

7 files changed

+415
-135
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Install Dependencies
5353
run: |
5454
python -m pip install --upgrade pip
55-
pip install .[lint,test]
55+
pip install .[lint,test,mcp]
5656
5757
- name: Run MyPy
5858
run: mypy .

docs/commands/cluster.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CLI commands for interacting with the Silverback Platform.
99
.. click:: silverback._cli:cluster
1010
:prog: silverback cluster
1111
:nested: full
12-
:commands: new, update, list, info, health
12+
:commands: new, update, list, info, health, mcp
1313

1414
.. click:: silverback._cli:workspaces
1515
:prog: silverback cluster workspaces
@@ -34,4 +34,4 @@ CLI commands for interacting with the Silverback Platform.
3434
.. click:: silverback._cli:pay
3535
:prog: silverback cluster pay
3636
:nested: full
37-
:commands: create, add-time, cancel
37+
:commands: create, add-time, cancel

docs/userguides/managing.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,40 @@ Lastly, if you ever feel like you want to delete your Cluster, you can cancel th
4545
If you are the owner of the Stream, you can do this via the [`silverback cluster pay cancel`][silverback-cluster-pay-cancel] command.
4646
Only the owner may do this, so if you are not the owner you should contact them to have them do that action for you.
4747

48+
## Model Context Server
49+
50+
The Silverback package ships with an MCP ([Model Context Protocol](https://modelcontextprotocol.io/quickstart/user)) which you can use via the [`silverback cluster mcp`][silverback-cluster-mcp] command.
51+
This MCP server must be configured to run locally, and the easiest way to do so is to configure it in your LLM of choice.
52+
The config for using this with Claude Desktop is as follows:
53+
54+
`~/.config/Claude/claude_desktop_config.json`:
55+
56+
```json
57+
{
58+
"mcpServers": {
59+
... # Other MCP servers go here
60+
"silverback": {
61+
"command": "<path to `uvx` or `uv` binary>",
62+
"args": [
63+
"silverback[mcp]",
64+
"cluster",
65+
"mcp"
66+
# Add args `--cluster <cluster name>` to use a Cluster other than your default
67+
]
68+
}
69+
}
70+
}
71+
```
72+
73+
Once that has been configured, you can ask your LLM to do things like check the status of your cluster, summarize logs of running bots, and restart bots just be commanding it through a chat interface!
74+
75+
```{notice}
76+
The MCP will use the context from [`silverback login`][silverback-login] to execute, so be sure to log in before starting.
77+
```
78+
4879
[silverback-cluster-info]: ../commands/cluster.html#silverback-cluster-info
4980
[silverback-cluster-list]: ../commands/cluster.html#silverback-cluster-list
81+
[silverback-cluster-mcp]: ../commands/cluster.html#silverback-cluster-mcp
5082
[silverback-cluster-new]: ../commands/cluster.html#silverback-cluster-new
5183
[silverback-cluster-pay-add-time]: ../commands/cluster.html#silverback-cluster-pay-add-time
5284
[silverback-cluster-pay-cancel]: ../commands/cluster.html#silverback-cluster-pay-cancel

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
from setuptools import find_packages, setup
44

55
extras_require = {
6+
"mcp": [
7+
"fastmcp", # MCP Server & AI Computer Use
8+
],
69
"test": [ # `test` GitHub Action jobs uses this
710
"pytest>=6.0", # Core testing package
811
"pytest-xdist", # Multi-process runner
@@ -44,6 +47,7 @@
4447
+ extras_require["doc"]
4548
+ extras_require["release"]
4649
+ extras_require["dev"]
50+
+ extras_require["mcp"]
4751
)
4852

4953
with open("./README.md") as readme:

0 commit comments

Comments
 (0)