内容
# 我是谁 - MCP 服务器
一个 [模型上下文协议](https://modelcontextprotocol.io) 服务器,暴露一个人的结构化职业资料 — 经验、项目、技能、教育、认证 — 作为 MCP 工具。指向克劳德(或任何 MCP 客户端)并让它从真实数据中回答关于该人的问题,而不是猜测。
一个软件包,三种使用方式:
- **库** — `npm i whoami-mcp`,使用工具构建自己的集成。
- **本地(标准输入/输出)** — `npx whoami-mcp` 用于克劳德桌面版。
- **可部署(HTTP)** — 一个无状态的 Streamable-HTTP 服务器,您可以托管(支持 Docker)。
## 安装
一键安装 — 选择您的客户端:
[](cursor://anysphere.cursor-deeplink/mcp/install?name=whoami&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIndob2FtaS1tY3AiXSwiZW52Ijp7IlBST0ZJTEVfUEFUSCI6Ii9hYnMvcGF0aC90by9wcm9maWxlLmpzb24ifX0=)
[](https://insiders.vscode.dev/redirect/mcp/install?name=whoami&config=%7B%22command%22%3A%20%22npx%22%2C%22args%22%3A%20%5B%22-y%22%2C%20%22whoami-mcp%22%5D%2C%22env%22%3A%20%7B%22PROFILE_PATH%22%3A%20%22%24%7Binput%3AprofilePath%7D%22%7D%7D)
或者按照每个客户端的指南:
| 客户端 | 指南 |
|---|---|
| Cursor | [installation/install-cursor.md](installation/install-cursor.md) |
| 克劳德桌面版 | [installation/install-claude-desktop.md](installation/install-claude-desktop.md) |
| 克劳德代码 | [installation/install-claude-code.md](installation/install-claude-code.md) |
| VS Code(Copilot) | [installation/install-vscode.md](installation/install-vscode.md) |
| Windsurf | [installation/install-windsurf.md](installation/install-windsurf.md) |
| 远程 / HTTP 部署 | [installation/install-http.md](installation/install-http.md) |
安装后,指向服务器到 [您的个人资料](#您的个人资料)。
## 目录
- [安装](#安装)
- [工具](#工具)
- [聊天(可选)](#聊天(可选))
- [您的个人资料](#您的个人资料)
- [本地(标准输入/输出) — 克劳德桌面版](#本地(标准输入/输出)—克劳德桌面版)
- [部署(Streamable HTTP)](#部署(streamable-http))
- [基于库构建](#基于库构建)
- [布局](#布局)
- [许可证](#许可证)
## 工具
| 工具 | 返回值 |
|---|---|
| `get_profile` | 姓名、角色、公司、地点、简介、可用性、首选技术栈、链接 |
| `get_experience` | 工作经历:公司、角色、日期、描述、成就 |
| `get_projects` | 项目:技术栈、解决问题、您的具体角色、链接 |
| `get_skills` | 按类别划分的技能,附带熟练程度 |
| `get_education` | 教育经历 + 专业认证 |
## 聊天(可选)
设置聊天提供程序,服务器将获得一个额外的 **`ask`** 工具 — 它会以该人的口吻回答自由形式的问题,基于个人资料,而不是仅仅返回原始数据。默认情况下关闭(数据工具无需开启即可使用)。
它讲的是 **OpenAI-compatible `/chat/completions`** API,因此 *任何* 提供程序都可以使用 — 设置一个基本 URL + 模型(+ 密钥,如果需要):
| 提供程序 | `CHAT_BASE_URL` | `CHAT_MODEL` |
|---|---|---|
| OpenAI | `https://api.openai.com/v1` | `gpt-4o-mini` |
| Google | `https://generativelanguage.googleapis.com/v1beta/openai` | `gemini-2.0-flash` |
| Ollama(本地,无密钥) | `http://localhost:11434/v1` | `llama3.2` |
| Groq | `https://api.groq.com/openai/v1` | `llama-3.3-70b-versatile` |
```bash
CHAT_BASE_URL=https://api.openai.com/v1 CHAT_API_KEY=sk-... CHAT_MODEL=gpt-4o-mini \
PROFILE_PATH=data/profile.json npm run start:http
```
环境变量:`CHAT_BASE_URL`,`CHAT_MODEL`(两者均需要启用),`CHAT_API_KEY`
(可选),`CHAT_TEMPERATURE`(默认为 `0.4`)。参见 [`.env.example`](.env.example)。
## 您的个人资料
每个服务器都读取一个包含六个顶级键的个人资料 JSON:`basic`、`experience`、`projects`、`skills`、`education`、`certifications`。参见 [`data/profile.example.json`](data/profile.example.json) 以获取确切的结构。
```bash
cp data/profile.example.json data/profile.json # 然后编辑
```
通过以下方式将服务器指向它:
- `PROFILE_URL` — 通过 HTTP 获取 JSON(GitHub 代码片段、托管的个人资料 API、任何端点)
- `PROFILE_PATH` — 读取此文件
- `./profile.json` — 工作目录中的默认文件
## 本地(标准输入/输出) — 克劳德桌面版
```json
{
"mcpServers": {
"whoami": {
"command": "npx",
"args": ["-y", "whoami-mcp"],
"env": { "PROFILE_PATH": "/abs/path/to/your/profile.json" }
}
}
}
```
从克隆开始:`npm install && npm run build`,然后将 `command`/`args` 指向 `node /abs/path/to/dist/stdio.js`。
> 其他客户端:[Cursor](installation/install-cursor.md) · [克劳德代码](installation/install-claude-code.md) · [VS Code](installation/install-vscode.md) · [Windsurf](installation/install-windsurf.md)。
## 部署(Streamable HTTP)
一个长期运行的无状态 HTTP 服务器 — 在任何运行容器的地方托管它。
```bash
docker compose up --build # 在 http://localhost:8080/mcp 提供 MCP 服务
```
无需 Docker:
```bash
npm install && npm run build
PROFILE_PATH=data/profile.json npm run start:http
```
将 MCP 客户端连接到端点:
```json
{ "mcpServers": { "whoami": { "url": "http://localhost:8080/mcp" } } }
```
健康检查:`GET /health` → `{"status":"ok"}`。
> 完整的部署 + 远程客户端指南:[installation/install-http.md](installation/install-http.md)。
## 基于库构建
```bash
npm i whoami-mcp
```
```ts
import { registerTools, type NormalizedProfile } from "whoami-mcp";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
const server = new McpServer({ name: "whoami", version: "1.0.0" });
registerTools(server, profile); // profile: NormalizedProfile
```
`whoami-mcp/http` 还导出了 `createHttpHandler(profile, opts)` 用于 Next.js / fetch 运行时。
## 布局
```
src/
index.ts 库入口 — TOOLS、registerTools、类型
http.ts createHttpHandler(fetch/Next 工厂) → 作为 whoami-mcp/http 导出
tools.ts 五个工具定义
types.ts NormalizedProfile + 工具类型
register.ts registerTools(server, profile)
loadProfile.ts 读取 PROFILE_PATH / ./profile.json
stdio.ts bin: whoami-stdio
http-server.ts bin: whoami-http(可部署,SDK StreamableHTTP)
```
```bash
npm install
npm run build
```
## 许可证
MIT — 参见 [LICENSE](./LICENSE)。