
使用 Tailscale 服务的身份感知 MCP 服务器示例。
概览
创建一个识别识别的MCP服务器,运行在您的私有Tailscale网络(Tailnet)内。本示例利用了传递给运行在Tailscale服务背后的应用程序的身份头部。 以此为起点,你可以创建具备身份感知能力(能够访问登录用户邮箱)并代表用户访问内部API或服务的MCP服务器。 1. 如果你还没有 Tailnet 设置,需要注册一个。2. 创建一个 API 认证密钥,并保存在本项目根目录中的 .env 文件,格式为:TS_AUTHKEY=tskey-auth-...3. 安装 Docker 后,运行 docker compose up 启动服务器。 这样会启动两个容器。MCP服务器和运行Tailscale的Tailscale容器作为你的tailnet代理。 如果你有一个支持直接访问流式HTTP MCP服务器的MCP客户端,那么你应该可以通过指向[[T0]来连接该服务器。
概述(AI 翻译)
创建一个识别识别的MCP服务器运行在您的私有Tailscale网络(Tailnet)内。本示例利用了传递给运行在tailscale serve后方的应用程序的身份头部。
以此为起点,你可以创建具备身份感知能力(能够访问登录用户邮箱)并代表用户访问内部API或服务的MCP服务器。
说明
启动服务器
- 如果你还没有Tailnet设置,你需要注册一个。
- 创建一个API认证密钥,并将其保存在本项目根目录中的
.env文件中,格式为:TS_AUTHKEY=tskey-auth-... - 已安装 Docker 后,运行
docker compose up启动服务器。
这将启动两个容器。MCP服务器和运行tailscale serve的Tailscale容器作为你的tailnet代理。
使用服务器
如果你有一个支持直接访问流式HTTP MCP服务器的MCP客户端,那么你应该可以通过指向https://ts-mcp-echo.yourtailnetname.ts.net/mcp来连接服务器。
克劳德桌面
本页由 AI 翻译,技术细节请以原文为准。
README
Identity Aware MCP Server for Tailscale
Create an identiy aware MCP server that runs inside your private Tailscale network (Tailnet). This example leverages identity headers that are passed through to applications running behind tailscale serve.
Using this as starting point you can create MCP servers that are identity aware (with access to the logged in user’s email) and can access internal APIs or services on thier behalf.
Instructions
Starting the Server
- If you don’t already have a Tailnet setup you’ll need to signup for one.
- Create an API auth key and save it into a
.envfile in the root of this project with the following format:TS_AUTHKEY=tskey-auth-... - With Docker already installed, run
docker compose upto start the server.
This will spin up two containers. The MCP server and a Tailscale container running tailscale serve as a proxy to your tailnet.
Using the Server
If you have an MCP Client that supports direct access to Streaming HTTP MCP servers, then you should be able to connect to the server by pointing it to https://ts-mcp-echo.yourtailnetname.ts.net/mcp.
Claude Desktop
Claude desktop does not currently support remote MCP servers (only stdio), but you can use the mcp-remote tool (or any other proxy) to connect to it.
-
Install mcp-remote with
npm install -g mcp-remote -
Add the following configuration to your
claude_desktop_config.jsonfile:{ "mcpServers": { "tailscale-remote-echo-example": { "command": "npx", "args": [ "mcp-remote", "https://ts-mcp-echo.yourtailnetname.ts.net/mcp" ] } } }You can find your tailnet name by visiting the Tailscale admin console DNS page.
-
Restart Claude Desktop.
-
You should now see a new MCP server called
tailscale-remote-echo-examplewith agreettool. -
Ask Claude
Who am I logged into my tailnet as?allow the tool, and wait for the response!
安装
npx mcp-remote https://ts-mcp-echo.yourtailnetname.ts.net/mcp配置
{
"mcpServers": {
"tailscale-remote-echo-example": {
"command": "npx",
"args": [
"mcp-remote",
"https://ts-mcp-echo.yourtailnetname.ts.net/mcp"
]
}
}
}