# PR Description
Consider this PR the result of a full pass through of this repository.
## Add helper for adding tools to an `MCPApp`
You can now add all of the tools in a module to an `MCPApp` via
`app.add_tools_from_module(...)`
## Edit what `arcade new` generates
First, I updated the backend to use hatchling.
Second, the structure generated before this PR was simple, but did not
create a proper Python module.
This hindered developers in the following ways:
1. Difficult to add the tools in your server to an evaluation suite
2. Difficult to add more than one tool to an MCPApp at a time
3. All other niceties that come with being able to import modules
```
# Before
server/
├── .env.example
├── server.py
└── pyproject.toml
```
This PR updates the structure generated such that a valid Python module
is generated:
```
# After
server/
├── pyproject.toml
└── src/
└── server/
├── __init__.py
├── .env.example
└── server.py
```
## Fix Tool Chaining
`self._ctx.server.executor.run(...)` was being called, but `MCPServer`
does not have an instance of `ToolExecutor` (and it's not intended to be
an instance anyways). I updated `Tool.call_raw` to pass the programmatic
tool call through the `MCPServer._handle_call_tool`. This means that the
programmatic tool calls now go through the same steps that a typical
tool call (initiated by the MCP client) would.
This means that **toolA**, which specifies **requirementsA**, is
permitted to call **toolB**, which specifies **requirementsB**, without
needing to explicitly declare or satisfy **requirementsB**. I believe
this is acceptable because the secrets and/or auth token associated with
**toolB's** `Context` are not exposed to **toolA**, and the secrets
and/or auth token associated with **toolA's** `Context` are not exposed
to **toolB**.
## Fix User Elicitation
1. The read & write streams were created with a maximum queue size of 0.
I increased this to 100.
2. I updated `ServerSession`'s run loop to both read messages from the
stream & process them concurrently. This enables server initiated
requests (like user elicitation and progress reporting) to be handled
while tools are being executed. Otherwise, the server initiated requests
would wait for the tool to finish executing and the tool execution would
wait for the server initiated request to finish.
3.
## Fix Progress Reporting
Progress tokens sent by the client were not being stored. Therefore
there was no way to notify a client with progress updates. I am now
storing the `progressToken`, along with other `_meta` sent from the
client, in the `ServerSession`'s `_request_meta`. I am setting
`_request_meta` whenever the `MCPServer` is handling an incoming message
from a client.
## Fix handling of server names with spaces
Before:
Server name: "The simple server name"
Tool name: whisper_secret
Name seen by client: "The_simple_server_name_WhisperSecret"
After
Server name: "The simple server name"
Tool name: whisper_secret
Name seen by client: "TheSimpleServerName_WhisperSecret"
## Add Integration Tests
The stdio integration test is much more comprehensive than the http
integration test. These tests will let me sleep a bit more at night
## Add Example MCP Servers
Example servers for sampling, user-elicitation, progress reporting,
logging, tool chaining, combining prebuilt tools with custom tools, tool
secrets, tool auth, evaluations, and more!
## Add Docker template
Added a Docker template for running an MCP server in Docker (and removed
the old docker stuff)
89 lines
2.4 KiB
Markdown
89 lines
2.4 KiB
Markdown
# Docker Setup for MCP Servers
|
|
|
|
This directory contains a generalized Docker configuration template that can be used with any MCP server in this repository.
|
|
|
|
## Quick Start
|
|
|
|
1. **Copy the Docker files to your MCP server directory:**
|
|
|
|
```bash
|
|
cp -r examples/docker-template/docker your-mcp-server/
|
|
cp examples/docker-template/.dockerignore your-mcp-server/
|
|
```
|
|
|
|
2. **Build and run:**
|
|
|
|
```bash
|
|
cd your-mcp-server
|
|
docker-compose -f docker/docker-compose.yml up --build
|
|
```
|
|
|
|
## Configuration
|
|
|
|
### Package Detection
|
|
|
|
The Dockerfile uses the package name from `pyproject.toml` by reading the `[project] name` field. It expects your server file at `src/<package_name>/server.py` (where `<package_name>` is from `pyproject.toml`).
|
|
|
|
If the server file is not found at this location, then the build will fail with an error message showing the detected package name and available directories in `src/`.
|
|
|
|
### Environment Variables
|
|
|
|
- `ARCADE_SERVER_TRANSPORT`: The transport protocol to use
|
|
- Default: `http`
|
|
- Options: `http`, `stdio`
|
|
- `ARCADE_SERVER_PORT`: The port to run the server on
|
|
- Default: `8001`
|
|
- `ARCADE_SERVER_HOST`: The host to bind to
|
|
- Default: `0.0.0.0`
|
|
|
|
### Example: Simple MCP Server
|
|
|
|
```bash
|
|
# From examples/mcp_servers/simple/
|
|
docker-compose -f docker/docker-compose.yml up --build
|
|
```
|
|
|
|
You can customize the port by editing `docker/docker-compose.yml` and changing both the `ARCADE_SERVER_PORT` environment variable and the port mapping.
|
|
|
|
## Building the Image
|
|
|
|
```bash
|
|
docker build \
|
|
-f docker/Dockerfile \
|
|
-t your-mcp-server \
|
|
.
|
|
```
|
|
|
|
## Running with Docker
|
|
|
|
```bash
|
|
docker run -p 8001:8001 \
|
|
-e ARCADE_SERVER_TRANSPORT=http \
|
|
-e ARCADE_SERVER_HOST=0.0.0.0 \
|
|
-e ARCADE_SERVER_PORT=8001 \
|
|
your-mcp-server
|
|
```
|
|
|
|
## Features
|
|
|
|
- **Automatic package detection**: Reads package name from `pyproject.toml`
|
|
- **Standard server location**: Expects server file at `src/<package>/server.py`
|
|
- **Secure by default**: Runs as non-root user
|
|
- **Arcade environment variable support**: Uses `ARCADE_SERVER_*` environment variables
|
|
- **Environment-based config**: Easy customization via environment variables
|
|
- **uv integration**: Uses uv for fast dependency management
|
|
- **Lightweight**: Based on Python 3.11 Bookworm slim image with uv
|
|
|
|
## Connecting from Cursor
|
|
|
|
Add to your `~/.cursor/mcp.json`:
|
|
|
|
```json
|
|
"your-server-name": {
|
|
"name": "your-server-name",
|
|
"type": "stream",
|
|
"url": "http://localhost:8001"
|
|
}
|
|
```
|
|
|
|
Then restart Cursor to connect to the server.
|