forked from microsoft/semanticworkbench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version of mcp-tunnel (microsoft#350)
Supports arbitrary SSE MCP servers, with defaults that match our vscode and office ports. - Sets up tunnel with `devtunnel` - Gets URI and access token for tunnel - Generates assistant config file to be imported
- Loading branch information
1 parent
83ec66f
commit 8a68d6a
Showing
12 changed files
with
772 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"editor.bracketPairColorization.enabled": true, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": "explicit", | ||
"source.fixAll": "explicit" | ||
}, | ||
"editor.guides.bracketPairs": "active", | ||
"editor.formatOnPaste": true, | ||
"editor.formatOnType": true, | ||
"editor.formatOnSave": true, | ||
"files.eol": "\n", | ||
"files.trimTrailingWhitespace": true, | ||
"python.analysis.autoFormatStrings": true, | ||
"python.analysis.autoImportCompletions": true, | ||
"python.analysis.diagnosticMode": "workspace", | ||
"python.analysis.fixAll": [ | ||
"source.unusedImports" | ||
], | ||
"python.analysis.inlayHints.functionReturnTypes": true, | ||
"python.analysis.typeCheckingMode": "standard", | ||
"python.defaultInterpreterPath": "${workspaceFolder}/.venv", | ||
"python.testing.pytestEnabled": false, | ||
"[python]": { | ||
"editor.defaultFormatter": "charliermarsh.ruff", | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "explicit", | ||
"source.unusedImports": "explicit", | ||
"source.organizeImports": "explicit", | ||
"source.formatDocument": "explicit" | ||
} | ||
}, | ||
"ruff.nativeServer": "on", | ||
"search.exclude": { | ||
"**/.venv": true, | ||
"**/.data": true, | ||
"**/__pycache__": true | ||
}, | ||
// For use with optional extension: "streetsidesoftware.code-spell-checker" | ||
"cSpell.ignorePaths": [ | ||
".venv", | ||
"node_modules", | ||
"package-lock.json", | ||
"settings.json", | ||
"uv.lock" | ||
], | ||
"cSpell.words": [ | ||
"asyncio", | ||
"deepmerge", | ||
"fastmcp", | ||
"interoperating", | ||
"Lifecycles", | ||
"pydantic", | ||
"pyright", | ||
"pytest" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
repo_root = $(shell git rev-parse --show-toplevel) | ||
include $(repo_root)/tools/makefiles/python.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# MCP Tunnel | ||
|
||
A command-line tool for managing secure tunnels to local Model Context Protocol (MCP) servers. | ||
|
||
## Overview | ||
|
||
MCP Tunnel simplifies the process of exposing locally running MCP servers to the internet through secure tunnels. This enables AI assistants like Codespace assistant to connect to your local MCP servers, allowing them to access local resources, files, and functionality. | ||
|
||
The tool uses Microsoft's DevTunnel service to create secure tunnels from the internet to your local machine. It can manage multiple tunnels simultaneously and generates the necessary configuration files for connecting your Codespace assistant to these tunnels. | ||
|
||
## Prerequisites | ||
|
||
- Python 3.11 or higher | ||
- [Microsoft DevTunnel CLI](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started) installed and available in your PATH | ||
- A Microsoft account (to log in to DevTunnel) | ||
|
||
## Installation | ||
|
||
Install MCP Tunnel using make from the `mcp-tunnel` directory: | ||
|
||
```bash | ||
make install | ||
``` | ||
|
||
## Usage | ||
|
||
### Basic Usage | ||
|
||
Start tunnels for default MCP servers (vscode on port 6010 and office on port 25566): | ||
|
||
```bash | ||
mcp-tunnel | ||
``` | ||
|
||
### Custom Servers | ||
|
||
Specify custom server names and ports: | ||
|
||
```bash | ||
mcp-tunnel --servers "myserver:8080,anotherserver:9000" | ||
``` | ||
|
||
### Output | ||
|
||
When you run MCP Tunnel, it will: | ||
|
||
1. Check if DevTunnel CLI is installed and you're logged in | ||
2. Create tunnels for each specified server | ||
3. Start tunnel processes and display their output with color-coding | ||
4. Generate a configuration file at `~/.mcp-tunnel/config.yaml` | ||
5. Keep tunnels running until you press Ctrl+C | ||
|
||
Example output: | ||
|
||
``` | ||
DevTunnel CLI detected and user is logged in | ||
Starting tunnels for servers: vscode, office | ||
Starting tunnel for vscode on port 6010... | ||
Starting tunnel for office on port 25566... | ||
[vscode] Tunnel vscode-a1b2c3 is online and ready to use | ||
[vscode] Using tunnel URL: https://a1b2c3d4-6010.usw2.devtunnels.ms | ||
[office] Tunnel office-a1b2c3 is online and ready to use | ||
[office] Using tunnel URL: https://e5f6g7h8-25566.usw2.devtunnels.ms | ||
Config file written to: /home/user/.mcp-tunnel/config.yaml | ||
All tunnels started. Press Ctrl+C to stop all tunnels. | ||
``` | ||
|
||
## Configuration | ||
|
||
MCP Tunnel generates a configuration file at `~/.mcp-tunnel/config.yaml` that can be used to connect your AI assistant to the tunnels. The configuration includes: | ||
|
||
- SSE endpoints for each tunnel | ||
- Authentication headers | ||
|
||
You can use this configuration with the Codespace assistant by importing it from the Assistant Configuration screen. | ||
|
||
## Troubleshooting | ||
|
||
### DevTunnel CLI Not Found | ||
|
||
If you see an error about the DevTunnel CLI not being found: | ||
|
||
1. Install the DevTunnel CLI by following the [official instructions](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started) | ||
2. Make sure it's in your PATH | ||
3. Test that it works by running `devtunnel --version` | ||
|
||
### Not Logged In | ||
|
||
If you're not logged in to DevTunnel: | ||
|
||
```bash | ||
devtunnel login | ||
``` | ||
|
||
### Tunnels Not Starting | ||
|
||
If tunnels aren't starting, check: | ||
|
||
1. That the ports you specified are correct | ||
2. That your local MCP servers are running on those ports | ||
3. That the ports aren't being blocked by a firewall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from ._main import tunnel_servers | ||
|
||
__all__ = ["tunnel_servers"] |
Oops, something went wrong.