This PR adds the ability to pass through all environment variables to
the server, using the flag `--pass-environment` (default off).
This change allows a compose spec like this to access all environment
variables from an env_file (as well as PATH):
```yaml
server-brave-search:
image: mcp-proxy:latest
env_file: .brave.env
# ENTRYPOINT from custom SSE-only image, for context
entrypoint: ["mcp-proxy", "--sse-host=0.0.0.0", "--sse-port=8080", "--pass-environment", "--"]
command: ["npx", "--yes", "@modelcontextprotocol/server-brave-search"]
```
The motivation behind this is I am developing in Docker Compose, with a
custom client and multiple servers. I made a debian-based mcp-proxy
image, with an entrypoint that set some SSE settings. When it came to
adding brave search, I spent a bit of time struggling against var
interpolation and an overridden entrypoint (cause: you can't access env
vars in entrypoints, I think). I figured passing through all environment
variables would be easier (and safe in a container).
I started adding tests for this, but found myself refactoring
\_\_main\_\_.py quite a bit to make it more testable. I've left that for
now in the aim of an easy-to-review PR, but am happy to continue that
effort if you'd like? Essentially breaking out the argument parser and
the SSE client/server parts into functions and validating their config.
Thanks again for this tool - it's made adding support for stdio servers
in our client much easier!
---------
Co-authored-by: Sergey Parfenyuk <myseverality@gmail.com>
I have replaced the `--api-access-token` argument with the more generic
`--headers` argument for SSE. This will allow for other auth mechanisms
such as api keys as well. Intended usage:
```sh
# API key
mcp-proxy http://example.io/sse --headers x-api-key my-super-secret-api-key
# Bearer token
mcp-proxy http://example.io/sse --headers Authorization 'Bearer my-super-secret-bearer-token'
# Multiple headers
mcp-proxy http://example.io/sse --headers Authorization 'Bearer my-super-secret-bearer-token' --headers x-api-key my-super-secret-api-key
```
This pull request introduces the following updates:
- **Dockerfile**: Introduces a Dockerfile to package the MCP for
deployment across various environments.
- **Smithery Configuration**: Adds a Smithery YAML file, which specifies
how to start the MCP and the configuration options it supports. It
allows you to [deploy](https://smithery.ai/docs/deployments) your MCP to
[Smithery](https://smithery.ai?utm_campaign=pr), serving it over SSE so
end-users do not need to install additional dependencies. To deploy,
merge this PR, then visit your [server
page](https://smithery.ai/server/mcp-proxy?utm_campaign=pr&modal=claim)
and click "Deploy" under the deployments page.
Please review these updates to verify their accuracy for your server and
feel free to customize it to your needs. Let me know if you have any
questions. 🙂
---------
Co-authored-by: Sergey Parfenyuk <myseverality@gmail.com>
* Refine CLI and reflect the change in the documentation
* Update README.md with concise examples
* Bump version
---------
Co-authored-by: Allen Porter <allen.porter@gmail.com>
* Add library for serving an sse server proxying a stdio server
* Change context manager for running server in the background thread
* Fix lint errors in new test fixture
* Update starlette response routing
* Fix ruff format errors
* Fix ruff format errors
* Fix typos in SseServerSettigs
* Rename host to bind host and update to localhost
* Update for new import location
* Update imports based on ruff rules
* Update src/mcp_proxy/sse_server.py
Co-authored-by: Guillaume Raille <guillaume.raille@gmail.com>