translation/translated/documents/course/02-agent-tools-mcp/14-getting-github-mcp-url.md

36 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 获取 Smithery GitHub MCP URL
首先,您需要获取一个 Smithery GitHub MCP URL。这通常需要
1. 设置一个 Smithery 账户
2. 使用您的 GitHub 账户创建个人访问令牌
3. 通过 Smithery 包获取您唯一的 MCP URL
对于此示例,我们将使用环境变量来存储可在 Smithery 界面中找到的 Smithery API 密钥和配置文件名。
```bash
# 将此添加到您的 .env 文件中
SMITHERY_API_KEY=your_smithery_api_key
SMITHERY_PROFILE=your_smithery_profile_name
```
使用环境变量可以保持您的配置安全和灵活。它还防止敏感信息被提交到您的仓库。
我们将使用 Smithery 包进行身份验证并为 MCP 服务器配置创建一个可流的 HTTP URL
```bash
pnpm install @smithery/sdk
```
```ts
import { createSmitheryUrl } from "@smithery/sdk";
const smitheryGithubMCPServerUrl = createSmitheryUrl(
"https://server.smithery.ai/@smithery-ai/github",
{
apiKey: process.env.SMITHERY_API_KEY,
profile: process.env.SMITHERY_PROFILE,
},
);
```