mirror of
https://github.com/upstash/context7.git
synced 2025-07-04 07:26:36 +00:00
Compare commits
126 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
13b7e107b4 | ||
![]() |
7c8267f7ba | ||
![]() |
68b75c77ef | ||
![]() |
e6bf5b80c2 | ||
![]() |
0385f9b0db | ||
![]() |
526e6040a3 | ||
![]() |
2c5d40aa96 | ||
![]() |
f18bbe4614 | ||
![]() |
98cd24504d | ||
![]() |
6dd432d5e0 | ||
![]() |
d38be6d974 | ||
![]() |
6b921c273e | ||
![]() |
dc215a85b2 | ||
![]() |
5446003880 | ||
![]() |
eeb654584d | ||
![]() |
fb0d7875d1 | ||
![]() |
e85d3d8a34 | ||
![]() |
ed30ceaad3 | ||
![]() |
f9d2b056b4 | ||
![]() |
9adaee2a17 | ||
![]() |
955188ecb2 | ||
![]() |
bcc3b97f3d | ||
![]() |
786693f788 | ||
![]() |
835f674696 | ||
![]() |
61b07d96d9 | ||
![]() |
cef57953c4 | ||
![]() |
a175d48a1d | ||
![]() |
8bc69debdc | ||
![]() |
b5735ebc50 | ||
![]() |
a47a3026f3 | ||
![]() |
e057538e9b | ||
![]() |
59fc2b4efd | ||
![]() |
069044e99e | ||
![]() |
e58addd388 | ||
![]() |
d2083b92a7 | ||
![]() |
7005d7d123 | ||
![]() |
a0a94eefe2 | ||
![]() |
fd2a2d6299 | ||
![]() |
0bf9466a14 | ||
![]() |
6a3c48a89f | ||
![]() |
f109390e00 | ||
![]() |
80e4aea67e | ||
![]() |
4f04e02851 | ||
![]() |
2e6c9a6c6b | ||
![]() |
2a3101dc43 | ||
![]() |
00937fafef | ||
![]() |
62ee37d861 | ||
![]() |
1042650638 | ||
![]() |
e66cdafe3c | ||
![]() |
a7b11bbee7 | ||
![]() |
f2f367d891 | ||
![]() |
8a8cfa1c82 | ||
![]() |
6629783835 | ||
![]() |
be254b0f02 | ||
![]() |
51ca970eeb | ||
![]() |
71fb2eaeca | ||
![]() |
8a275cb6da | ||
![]() |
f112d360c6 | ||
![]() |
b1445c2a40 | ||
![]() |
2f74fa3893 | ||
![]() |
10c0a0dd33 | ||
![]() |
ae6618cd15 | ||
![]() |
beb04d3267 | ||
![]() |
043bbd5fcc | ||
![]() |
5ac6fa1401 | ||
![]() |
e0775b3fa2 | ||
![]() |
fcd166d95f | ||
![]() |
c78b9bc54d | ||
![]() |
49e05298a4 | ||
![]() |
b425c6d2ea | ||
![]() |
fce7023012 | ||
![]() |
93b06e17e3 | ||
![]() |
7675df0999 | ||
![]() |
0a6273f6ac | ||
![]() |
1de2b52a55 | ||
![]() |
c55bfebb3f | ||
![]() |
6490a81afb | ||
![]() |
1755da4d49 | ||
![]() |
70b7b49d5f | ||
![]() |
d513d1a59f | ||
![]() |
f8472ff1ec | ||
![]() |
16d64493f3 | ||
![]() |
8222f21183 | ||
![]() |
e2952e9a39 | ||
![]() |
b9749394fb | ||
![]() |
c2f695d377 | ||
![]() |
2628a868c2 | ||
![]() |
e7047b4f16 | ||
![]() |
decae95458 | ||
![]() |
da11fccf75 | ||
![]() |
b0352b17e7 | ||
![]() |
e50ee0dfd3 | ||
![]() |
ce2a63a37a | ||
![]() |
886a65562a | ||
![]() |
197bf1c27e | ||
![]() |
44dbfba424 | ||
![]() |
d15109d326 | ||
![]() |
52786950a5 | ||
![]() |
d29a9457f3 | ||
![]() |
9d869a6927 | ||
![]() |
ec1aaff477 | ||
![]() |
5fc52df93c | ||
![]() |
35d4a10270 | ||
![]() |
a847b57140 | ||
![]() |
8610ec8814 | ||
![]() |
5326cc3890 | ||
![]() |
2da555d310 | ||
![]() |
ae8bb764d2 | ||
![]() |
523fc5fdde | ||
![]() |
eafcf592bb | ||
![]() |
f38c39f3a8 | ||
![]() |
dd2a68c019 | ||
![]() |
942a9e16a8 | ||
![]() |
cd0dce5926 | ||
![]() |
ebc1dbc79e | ||
![]() |
6435f1b27f | ||
![]() |
e9d951ca8c | ||
![]() |
fcd7310c34 | ||
![]() |
9a571f2132 | ||
![]() |
1755903edf | ||
![]() |
cb01c51100 | ||
![]() |
459e63d771 | ||
![]() |
171b298f7a | ||
![]() |
de773c1dfd | ||
![]() |
22e34fa4bf | ||
![]() |
15f30c7bae |
44
.github/workflows/check.yaml
vendored
Normal file
44
.github/workflows/check.yaml
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
name: Build Check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-bun-
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Run linter
|
||||
run: bun run lint:check
|
||||
|
||||
- name: Check formatting
|
||||
run: bun run format --check
|
||||
|
||||
- name: Build project
|
||||
run: bun run build
|
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@ -14,7 +14,11 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set env
|
||||
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
run: |
|
||||
VERSION="${GITHUB_REF##refs/*/}"
|
||||
# Remove 'v' prefix if it exists
|
||||
VERSION="${VERSION#v}"
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -172,4 +172,5 @@ dist
|
||||
.idea
|
||||
|
||||
# Finder (MacOS) folder config
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
package-lock.json
|
||||
|
@ -25,7 +25,8 @@ COPY package.json ./
|
||||
# Install only production dependencies
|
||||
RUN npm install --production --ignore-scripts
|
||||
|
||||
# Expose no ports (stdio only)
|
||||
# Expose HTTP port
|
||||
EXPOSE 8080
|
||||
|
||||
# Default command
|
||||
CMD ["node", "dist/index.js"]
|
||||
# Default command using CLI flags
|
||||
CMD ["node", "dist/index.js", "--transport", "http", "--port", "8080"]
|
||||
|
735
README.md
735
README.md
@ -2,7 +2,7 @@
|
||||
|
||||
[](https://context7.com) [](https://smithery.ai/server/@upstash/context7-mcp) [<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
[](./docs/README.zh-CN.md) [](./docs/README.ko.md) [](./docs/README.es.md) [](./docs/README.fr.md) [-purple)](./docs/README.pt-BR.md) [](./docs/README.it.md) [](./docs/README.id-ID.md) [](./docs/README.de.md) [](./docs/README.ru.md)
|
||||
[](./docs/README.zh-TW.md) [](./docs/README.zh-CN.md) [](./docs/README.ja.md) [](./docs/README.ko.md) [](./docs/README.es.md) [](./docs/README.fr.md) [-purple>)](./docs/README.pt-BR.md) [](./docs/README.it.md) [](./docs/README.id-ID.md) [](./docs/README.de.md) [](./docs/README.ru.md) [](./docs/README.tr.md) [](./docs/README.ar.md)
|
||||
|
||||
## ❌ Without Context7
|
||||
|
||||
@ -19,11 +19,11 @@ Context7 MCP pulls up-to-date, version-specific documentation and code examples
|
||||
Add `use context7` to your prompt in Cursor:
|
||||
|
||||
```txt
|
||||
Create a basic Next.js project with app router. use context7
|
||||
Create a Next.js middleware that checks for a valid JWT in cookies and redirects unauthenticated users to `/login`. use context7
|
||||
```
|
||||
|
||||
```txt
|
||||
Create a script to delete the rows where the city is "" given PostgreSQL credentials. use context7
|
||||
Configure a Cloudflare Worker script to cache JSON API responses for five minutes. use context7
|
||||
```
|
||||
|
||||
Context7 fetches up-to-date code examples and documentation right into your LLM's context.
|
||||
@ -34,33 +34,63 @@ Context7 fetches up-to-date code examples and documentation right into your LLM'
|
||||
|
||||
No tab-switching, no hallucinated APIs that don't exist, no outdated code generations.
|
||||
|
||||
## 🛠️ Getting Started
|
||||
## 📚 Adding Projects
|
||||
|
||||
Check out our [project addition guide](./docs/adding-projects.md) to learn how to add (or update) your favorite libraries to Context7.
|
||||
|
||||
## 🛠️ Installation
|
||||
|
||||
### Requirements
|
||||
|
||||
- Node.js >= v18.0.0
|
||||
- Cursor, Windsurf, Claude Desktop or another MCP Client
|
||||
|
||||
### Installing via Smithery
|
||||
<details>
|
||||
<summary><b>Installing via Smithery</b></summary>
|
||||
|
||||
To install Context7 MCP Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@upstash/context7-mcp):
|
||||
To install Context7 MCP Server for any client automatically via [Smithery](https://smithery.ai/server/@upstash/context7-mcp):
|
||||
|
||||
```bash
|
||||
npx -y @smithery/cli install @upstash/context7-mcp --client claude
|
||||
npx -y @smithery/cli@latest install @upstash/context7-mcp --client <CLIENT_NAME> --key <YOUR_SMITHERY_KEY>
|
||||
```
|
||||
|
||||
### Install in Cursor
|
||||
You can find your Smithery key in the [Smithery.ai webpage](https://smithery.ai/server/@upstash/context7-mcp).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Cursor</b></summary>
|
||||
|
||||
Go to: `Settings` -> `Cursor Settings` -> `MCP` -> `Add new global MCP server`
|
||||
|
||||
Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file is the recommended approach. You may also install in a specific project by creating `.cursor/mcp.json` in your project folder. See [Cursor MCP docs](https://docs.cursor.com/context/model-context-protocol) for more info.
|
||||
|
||||
> Since Cursor 1.0, you can click the install button below for instant one-click installation.
|
||||
|
||||
#### Cursor Remote Server Connection
|
||||
|
||||
[](https://cursor.com/install-mcp?name=context7&config=eyJ1cmwiOiJodHRwczovL21jcC5jb250ZXh0Ny5jb20vbWNwIn0%3D)
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Cursor Local Server Connection
|
||||
|
||||
[](https://cursor.com/install-mcp?name=context7&config=eyJjb21tYW5kIjoibnB4IC15IEB1cHN0YXNoL2NvbnRleHQ3LW1jcCJ9)
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -69,12 +99,14 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i
|
||||
<details>
|
||||
<summary>Alternative: Use Bun</summary>
|
||||
|
||||
[](https://cursor.com/install-mcp?name=context7&config=eyJjb21tYW5kIjoiYnVueCAteSBAdXBzdGFzaC9jb250ZXh0Ny1tY3AifQ%3D%3D)
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -85,12 +117,14 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i
|
||||
<details>
|
||||
<summary>Alternative: Use Deno</summary>
|
||||
|
||||
[](https://cursor.com/install-mcp?name=context7&config=eyJjb21tYW5kIjoiZGVubyBydW4gLS1hbGxvdy1lbnYgLS1hbGxvdy1uZXQgbnBtOkB1cHN0YXNoL2NvbnRleHQ3LW1jcCJ9)
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "deno",
|
||||
"args": ["run", "--allow-net", "npm:@upstash/context7-mcp"]
|
||||
"args": ["run", "--allow-env=NO_DEPRECATION,TRACE_DEPRECATION", "--allow-net", "npm:@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -98,41 +132,154 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i
|
||||
|
||||
</details>
|
||||
|
||||
### Install in Windsurf
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Windsurf</b></summary>
|
||||
|
||||
Add this to your Windsurf MCP config file. See [Windsurf MCP docs](https://docs.windsurf.com/windsurf/mcp) for more info.
|
||||
|
||||
#### Windsurf Remote Server Connection
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"serverUrl": "https://mcp.context7.com/sse"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Windsurf Local Server Connection
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Install in VS Code
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Trae</b></summary>
|
||||
|
||||
Use the Add manually feature and fill in the JSON configuration information for that MCP server.
|
||||
For more details, visit the [Trae documentation](https://docs.trae.ai/ide/model-context-protocol?_lang=en).
|
||||
|
||||
#### Trae Remote Server Connection
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Trae Local Server Connection
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"@upstash/context7-mcp"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in VS Code</b></summary>
|
||||
|
||||
[<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
[<img alt="Install in VS Code Insiders (npx)" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Install%20Context7%20MCP&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
Add this to your VS Code MCP config file. See [VS Code MCP docs](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for more info.
|
||||
|
||||
#### VS Code Remote Server Connection
|
||||
|
||||
```json
|
||||
{
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"Context7": {
|
||||
"type": "stdio",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"context7": {
|
||||
"type": "http",
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Install in Zed
|
||||
#### VS Code Local Server Connection
|
||||
|
||||
```json
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"context7": {
|
||||
"type": "stdio",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Visual Studio 2022</b></summary>
|
||||
|
||||
You can configure Context7 MCP in Visual Studio 2022 by following the [Visual Studio MCP Servers documentation](https://learn.microsoft.com/visualstudio/ide/mcp-servers?view=vs-2022).
|
||||
|
||||
Add this to your Visual Studio MCP config file (see the [Visual Studio docs](https://learn.microsoft.com/visualstudio/ide/mcp-servers?view=vs-2022) for details):
|
||||
|
||||
```json
|
||||
{
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"context7": {
|
||||
"type": "http",
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Or, for a local server:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"context7": {
|
||||
"type": "stdio",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For more information and troubleshooting, refer to the [Visual Studio MCP Servers documentation](https://learn.microsoft.com/visualstudio/ide/mcp-servers?view=vs-2022).
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Zed</b></summary>
|
||||
|
||||
It can be installed via [Zed Extensions](https://zed.dev/extensions?query=Context7) or you can add this to your Zed `settings.json`. See [Zed Context Server docs](https://zed.dev/docs/assistant/context-servers) for more info.
|
||||
|
||||
@ -142,7 +289,7 @@ It can be installed via [Zed Extensions](https://zed.dev/extensions?query=Contex
|
||||
"Context7": {
|
||||
"command": {
|
||||
"path": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
},
|
||||
"settings": {}
|
||||
}
|
||||
@ -150,15 +297,58 @@ It can be installed via [Zed Extensions](https://zed.dev/extensions?query=Contex
|
||||
}
|
||||
```
|
||||
|
||||
### Install in Claude Code
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Gemini CLI</b></summary>
|
||||
|
||||
See [Gemini CLI Configuration](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/configuration.md) for details.
|
||||
|
||||
1. Open the Gemini CLI settings file. The location is `~/.gemini/settings.json` (where `~` is your home directory).
|
||||
2. Add the following to the `mcpServers` object in your `settings.json` file:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If the `mcpServers` object does not exist, create it.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Claude Code</b></summary>
|
||||
|
||||
Run this command. See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#set-up-model-context-protocol-mcp) for more info.
|
||||
|
||||
#### Claude Code Remote Server Connection
|
||||
|
||||
```sh
|
||||
claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
|
||||
claude mcp add --transport http context7 https://mcp.context7.com/mcp
|
||||
```
|
||||
|
||||
### Install in Claude Desktop
|
||||
Or using SSE transport:
|
||||
|
||||
```sh
|
||||
claude mcp add --transport sse context7 https://mcp.context7.com/sse
|
||||
```
|
||||
|
||||
#### Claude Code Local Server Connection
|
||||
|
||||
```sh
|
||||
claude mcp add context7 -- npx -y @upstash/context7-mcp
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Claude Desktop</b></summary>
|
||||
|
||||
Add this to your Claude Desktop `claude_desktop_config.json` file. See [Claude Desktop MCP docs](https://modelcontextprotocol.io/quickstart/user) for more info.
|
||||
|
||||
@ -167,99 +357,355 @@ Add this to your Claude Desktop `claude_desktop_config.json` file. See [Claude D
|
||||
"mcpServers": {
|
||||
"Context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Using Docker
|
||||
</details>
|
||||
|
||||
If you prefer to run the MCP server in a Docker container:
|
||||
<details>
|
||||
<summary>
|
||||
<b>Install in Cline</b>
|
||||
</summary>
|
||||
|
||||
1. **Build the Docker Image:**
|
||||
You can easily install Context7 through the [Cline MCP Server Marketplace](https://cline.bot/mcp-marketplace) by following these instructions:
|
||||
|
||||
First, create a `Dockerfile` in the project root (or anywhere you prefer):
|
||||
1. Open **Cline**.
|
||||
1. Click the hamburger menu icon (☰) to enter the **MCP Servers** section.
|
||||
2. Use the search bar within the **Marketplace** tab to find *Context7*.
|
||||
3. Click the **Install** button.
|
||||
|
||||
<details>
|
||||
<summary>Click to see Dockerfile content</summary>
|
||||
</details>
|
||||
|
||||
```Dockerfile
|
||||
FROM node:18-alpine
|
||||
<details>
|
||||
<summary><b>Install in BoltAI</b></summary>
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install the latest version globally
|
||||
RUN npm install -g @upstash/context7-mcp@latest
|
||||
|
||||
# Expose default port if needed (optional, depends on MCP client interaction)
|
||||
# EXPOSE 3000
|
||||
|
||||
# Default command to run the server
|
||||
CMD ["context7-mcp"]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
Then, build the image using a tag (e.g., `context7-mcp`). **Make sure Docker Desktop (or the Docker daemon) is running.** Run the following command in the same directory where you saved the `Dockerfile`:
|
||||
|
||||
```bash
|
||||
docker build -t context7-mcp .
|
||||
```
|
||||
|
||||
2. **Configure Your MCP Client:**
|
||||
|
||||
Update your MCP client's configuration to use the Docker command.
|
||||
|
||||
*Example for a cline_mcp_settings.json:*
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*Note: This is an example configuration. Please refer to the specific examples for your MCP client (like Cursor, VS Code, etc.) earlier in this README to adapt the structure (e.g., `mcpServers` vs `servers`). Also, ensure the image name in `args` matches the tag used during the `docker build` command.*
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `DEFAULT_MINIMUM_TOKENS`: Set the minimum token count for documentation retrieval (default: 10000).
|
||||
|
||||
Examples:
|
||||
Open the "Settings" page of the app, navigate to "Plugins," and enter the following JSON:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"],
|
||||
"env": {
|
||||
"DEFAULT_MINIMUM_TOKENS": "10000"
|
||||
}
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Available Tools
|
||||
Once saved, enter in the chat `get-library-docs` followed by your Context7 documentation ID (e.g., `get-library-docs /nuxt/ui`). More information is available on [BoltAI's Documentation site](https://docs.boltai.com/docs/plugins/mcp-servers). For BoltAI on iOS, [see this guide](https://docs.boltai.com/docs/boltai-mobile/mcp-servers).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Using Docker</b></summary>
|
||||
|
||||
If you prefer to run the MCP server in a Docker container:
|
||||
|
||||
1. **Build the Docker Image:**
|
||||
|
||||
First, create a `Dockerfile` in the project root (or anywhere you prefer):
|
||||
|
||||
<details>
|
||||
<summary>Click to see Dockerfile content</summary>
|
||||
|
||||
```Dockerfile
|
||||
FROM node:18-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install the latest version globally
|
||||
RUN npm install -g @upstash/context7-mcp
|
||||
|
||||
# Expose default port if needed (optional, depends on MCP client interaction)
|
||||
# EXPOSE 3000
|
||||
|
||||
# Default command to run the server
|
||||
CMD ["context7-mcp"]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
Then, build the image using a tag (e.g., `context7-mcp`). **Make sure Docker Desktop (or the Docker daemon) is running.** Run the following command in the same directory where you saved the `Dockerfile`:
|
||||
|
||||
```bash
|
||||
docker build -t context7-mcp .
|
||||
```
|
||||
|
||||
2. **Configure Your MCP Client:**
|
||||
|
||||
Update your MCP client's configuration to use the Docker command.
|
||||
|
||||
_Example for a cline_mcp_settings.json:_
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
_Note: This is an example configuration. Please refer to the specific examples for your MCP client (like Cursor, VS Code, etc.) earlier in this README to adapt the structure (e.g., `mcpServers` vs `servers`). Also, ensure the image name in `args` matches the tag used during the `docker build` command._
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Windows</b></summary>
|
||||
|
||||
The configuration on Windows is slightly different compared to Linux or macOS (_`Cline` is used in the example_). The same principle applies to other editors; refer to the configuration of `command` and `args`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"github.com/upstash/context7-mcp": {
|
||||
"command": "cmd",
|
||||
"args": ["/c", "npx", "-y", "@upstash/context7-mcp@latest"],
|
||||
"disabled": false,
|
||||
"autoApprove": []
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Augment Code</b></summary>
|
||||
|
||||
To configure Context7 MCP in Augment Code, you can use either the graphical interface or manual configuration.
|
||||
|
||||
### **A. Using the Augment Code UI**
|
||||
|
||||
1. Click the hamburger menu.
|
||||
2. Select **Settings**.
|
||||
3. Navigate to the **Tools** section.
|
||||
4. Click the **+ Add MCP** button.
|
||||
5. Enter the following command:
|
||||
|
||||
```
|
||||
npx -y @upstash/context7-mcp@latest
|
||||
```
|
||||
|
||||
6. Name the MCP: **Context7**.
|
||||
7. Click the **Add** button.
|
||||
|
||||
Once the MCP server is added, you can start using Context7's up-to-date code documentation features directly within Augment Code.
|
||||
|
||||
---
|
||||
|
||||
### **B. Manual Configuration**
|
||||
|
||||
1. Press Cmd/Ctrl Shift P or go to the hamburger menu in the Augment panel
|
||||
2. Select Edit Settings
|
||||
3. Under Advanced, click Edit in settings.json
|
||||
4. Add the server configuration to the `mcpServers` array in the `augment.advanced` object
|
||||
|
||||
"augment.advanced": {
|
||||
"mcpServers": [
|
||||
{
|
||||
"name": "context7",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Once the MCP server is added, restart your editor. If you receive any errors, check the syntax to make sure closing brackets or commas are not missing.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Roo Code</b></summary>
|
||||
|
||||
Add this to your Roo Code MCP configuration file. See [Roo Code MCP docs](https://docs.roocode.com/features/mcp/using-mcp-in-roo) for more info.
|
||||
|
||||
#### Roo Code Remote Server Connection
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"type": "streamable-http",
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Roo Code Local Server Connection
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Zencoder</b></summary>
|
||||
|
||||
To configure Context7 MCP in Zencoder, follow these steps:
|
||||
|
||||
1. Go to the Zencoder menu (...)
|
||||
2. From the dropdown menu, select Agent tools
|
||||
3. Click on the Add custom MCP
|
||||
4. Add the name and server configuration from below, and make sure to hit the Install button
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"@upstash/context7-mcp@latest"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Once the MCP server is added, you can easily continue using it.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Amazon Q Developer CLI</b></summary>
|
||||
|
||||
Add this to your Amazon Q Developer CLI configuration file. See [Amazon Q Developer CLI docs](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-configuration.html) for more details.
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Qodo Gen</b></summary>
|
||||
|
||||
See [Qodo Gen docs](https://docs.qodo.ai/qodo-documentation/qodo-gen/qodo-gen-chat/agentic-mode/agentic-tools-mcps) for more details.
|
||||
|
||||
1. Open Qodo Gen chat panel in VSCode or IntelliJ.
|
||||
2. Click Connect more tools.
|
||||
3. Click + Add new MCP.
|
||||
4. Add the following configuration:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in JetBrains AI Assistant</b></summary>
|
||||
|
||||
See [JetBrains AI Assistant Documentation](https://www.jetbrains.com/help/ai-assistant/configure-an-mcp-server.html) for more details.
|
||||
|
||||
1. In JetBrains IDEs go to `Settings` -> `Tools` -> `AI Assistant` -> `Model Context Protocol (MCP)`
|
||||
2. Click `+ Add`.
|
||||
3. Click on `Command` in the top-left corner of the dialog and select the As JSON option from the list
|
||||
4. Add this configuration and click `OK`
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
5. Click `Apply` to save changes.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Install in Warp</b></summary>
|
||||
|
||||
See [Warp Model Context Protocol Documentation](https://docs.warp.dev/knowledge-and-collaboration/mcp#adding-an-mcp-server) for details.
|
||||
|
||||
1. Navigate `Settings` > `AI` > `Manage MCP servers`.
|
||||
2. Add a new MCP server by clicking the `+ Add` button.
|
||||
3. Paste the configuration given below:
|
||||
|
||||
```json
|
||||
{
|
||||
"Context7": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"@upstash/context7-mcp"
|
||||
],
|
||||
"env": {},
|
||||
"working_directory": null,
|
||||
"start_on_launch": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
4. Click `Save` to apply the changes.
|
||||
|
||||
</details>
|
||||
|
||||
## 🔨 Available Tools
|
||||
|
||||
Context7 MCP provides the following tools that LLMs can use:
|
||||
|
||||
- `resolve-library-id`: Resolves a general library name into a Context7-compatible library ID.
|
||||
- `libraryName` (required)
|
||||
- `get-library-docs`: Fetches documentation for a library using a Context7-compatible library ID.
|
||||
- `context7CompatibleLibraryID` (required)
|
||||
- `topic` (optional): Focus the docs on a specific topic (e.g., "routing", "hooks")
|
||||
- `tokens` (optional, default 10000): Max number of tokens to return. Values less than the configured `DEFAULT_MINIMUM_TOKENS` value or the default value of 10000 are automatically increased to that value.
|
||||
|
||||
## Development
|
||||
- `libraryName` (required): The name of the library to search for
|
||||
|
||||
- `get-library-docs`: Fetches documentation for a library using a Context7-compatible library ID.
|
||||
- `context7CompatibleLibraryID` (required): Exact Context7-compatible library ID (e.g., `/mongodb/docs`, `/vercel/next.js`)
|
||||
- `topic` (optional): Focus the docs on a specific topic (e.g., "routing", "hooks")
|
||||
- `tokens` (optional, default 10000): Max number of tokens to return. Values less than the default value of 10000 are automatically increased to 10000.
|
||||
|
||||
## 🛟 Tips
|
||||
|
||||
### Add a Rule
|
||||
> If you don’t want to add `use context7` to every prompt, you can define a simple rule in your `.windsurfrules` file in Windsurf or from `Cursor Settings > Rules` section in Cursor (or the equivalent in your MCP client) to auto-invoke Context7 on any code question:
|
||||
> ```toml
|
||||
> [[calls]]
|
||||
> match = "when the user requests code examples, setup or configuration steps, or library/API documentation"
|
||||
> tool = "context7"
|
||||
> ```
|
||||
> From then on you’ll get Context7’s docs in any related conversation without typing anything extra. You can add your use cases to the match part.
|
||||
|
||||
### Use Library Id
|
||||
> If you already know exactly which library you want to use, add its Context7 ID to your prompt. That way, Context7 MCP server can skip the library-matching step and directly continue with retrieving docs.
|
||||
> ```txt
|
||||
> implement basic authentication with supabase. use library /supabase/supabase for api and docs
|
||||
> ```
|
||||
> The slash syntax tells the MCP tool exactly which library to load docs for.
|
||||
|
||||
|
||||
|
||||
## 💻 Development
|
||||
|
||||
Clone the project and install dependencies:
|
||||
|
||||
@ -273,7 +719,27 @@ Build:
|
||||
bun run build
|
||||
```
|
||||
|
||||
### Local Configuration Example
|
||||
Run the server:
|
||||
|
||||
```bash
|
||||
bun run dist/index.js
|
||||
```
|
||||
|
||||
### CLI Arguments
|
||||
|
||||
`context7-mcp` accepts the following CLI flags:
|
||||
|
||||
- `--transport <stdio|http|sse>` – Transport to use (`stdio` by default).
|
||||
- `--port <number>` – Port to listen on when using `http` or `sse` transport (default `3000`).
|
||||
|
||||
Example with http transport and port 8080:
|
||||
|
||||
```bash
|
||||
bun run dist/index.js --transport http --port 8080
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary><b>Local Configuration Example</b></summary>
|
||||
|
||||
```json
|
||||
{
|
||||
@ -286,79 +752,112 @@ bun run build
|
||||
}
|
||||
```
|
||||
|
||||
### Testing with MCP Inspector
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Testing with MCP Inspector</b></summary>
|
||||
|
||||
```bash
|
||||
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
|
||||
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
</details>
|
||||
|
||||
### ERR_MODULE_NOT_FOUND
|
||||
## 🚨 Troubleshooting
|
||||
|
||||
If you see this error, try using `bunx` instead of `npx`.
|
||||
<details>
|
||||
<summary><b>Module Not Found Errors</b></summary>
|
||||
|
||||
If you encounter `ERR_MODULE_NOT_FOUND`, try using `bunx` instead of `npx`:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This often resolves module resolution issues, especially in environments where `npx` does not properly install or resolve packages.
|
||||
This often resolves module resolution issues in environments where `npx` doesn't properly install or resolve packages.
|
||||
|
||||
### ESM Resolution Issues
|
||||
</details>
|
||||
|
||||
If you encounter an error like: `Error: Cannot find module 'uriTemplate.js'` try running with the `--experimental-vm-modules` flag:
|
||||
<details>
|
||||
<summary><b>ESM Resolution Issues</b></summary>
|
||||
|
||||
For errors like `Error: Cannot find module 'uriTemplate.js'`, try the `--experimental-vm-modules` flag:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"--node-options=--experimental-vm-modules",
|
||||
"@upstash/context7-mcp@1.0.6"
|
||||
]
|
||||
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/context7-mcp@1.0.6"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### MCP Client Errors
|
||||
</details>
|
||||
|
||||
1. Try removing `@latest` from the package name.
|
||||
<details>
|
||||
<summary><b>TLS/Certificate Issues</b></summary>
|
||||
|
||||
2. Try using `bunx` as an alternative.
|
||||
Use the `--experimental-fetch` flag to bypass TLS-related problems:
|
||||
|
||||
3. Try using `deno` as an alternative.
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "--node-options=--experimental-fetch", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
4. Make sure you are using Node v18 or higher to have native fetch support with `npx`.
|
||||
</details>
|
||||
|
||||
## Disclaimer
|
||||
<details>
|
||||
<summary><b>General MCP Client Errors</b></summary>
|
||||
|
||||
1. Try adding `@latest` to the package name
|
||||
2. Use `bunx` as an alternative to `npx`
|
||||
3. Consider using `deno` as another alternative
|
||||
4. Ensure you're using Node.js v18 or higher for native fetch support
|
||||
|
||||
</details>
|
||||
|
||||
## ⚠️ Disclaimer
|
||||
|
||||
Context7 projects are community-contributed and while we strive to maintain high quality, we cannot guarantee the accuracy, completeness, or security of all library documentation. Projects listed in Context7 are developed and maintained by their respective owners, not by Context7. If you encounter any suspicious, inappropriate, or potentially harmful content, please use the "Report" button on the project page to notify us immediately. We take all reports seriously and will review flagged content promptly to maintain the integrity and safety of our platform. By using Context7, you acknowledge that you do so at your own discretion and risk.
|
||||
|
||||
## Context7 In Media
|
||||
## 🤝 Connect with Us
|
||||
|
||||
Stay updated and join our community:
|
||||
|
||||
- 📢 Follow us on [X](https://x.com/contextai) for the latest news and updates
|
||||
- 🌐 Visit our [Website](https://context7.com)
|
||||
- 💬 Join our [Discord Community](https://upstash.com/discord)
|
||||
|
||||
## 📺 Context7 In Media
|
||||
|
||||
- [Better Stack: "Free Tool Makes Cursor 10x Smarter"](https://youtu.be/52FC3qObp9E)
|
||||
- [Cole Medin: "This is Hands Down the BEST MCP Server for AI Coding Assistants"](https://www.youtube.com/watch?v=G7gK8H6u7Rs)
|
||||
- [Income stream surfers: "Context7 + SequentialThinking MCPs: Is This AGI?"](https://www.youtube.com/watch?v=-ggvzyLpK6o)
|
||||
- [Income Stream Surfers: "Context7 + SequentialThinking MCPs: Is This AGI?"](https://www.youtube.com/watch?v=-ggvzyLpK6o)
|
||||
- [Julian Goldie SEO: "Context7: New MCP AI Agent Update"](https://www.youtube.com/watch?v=CTZm6fBYisc)
|
||||
- [JeredBlu: "Context 7 MCP: Get Documentation Instantly + VS Code Setup"](https://www.youtube.com/watch?v=-ls0D-rtET4)
|
||||
- [Income stream surfers: "Context7: The New MCP Server That Will CHANGE AI Coding"](https://www.youtube.com/watch?v=PS-2Azb-C3M)
|
||||
- [Income Stream Surfers: "Context7: The New MCP Server That Will CHANGE AI Coding"](https://www.youtube.com/watch?v=PS-2Azb-C3M)
|
||||
- [AICodeKing: "Context7 + Cline & RooCode: This MCP Server Makes CLINE 100X MORE EFFECTIVE!"](https://www.youtube.com/watch?v=qZfENAPMnyo)
|
||||
- [Sean Kochel: "5 MCP Servers For Vibe Coding Glory (Just Plug-In & Go)"](https://www.youtube.com/watch?v=LqTQi8qexJM)
|
||||
|
||||
## Star History
|
||||
## ⭐ Star History
|
||||
|
||||
[](https://www.star-history.com/#upstash/context7&Date)
|
||||
|
||||
## License
|
||||
## 📄 License
|
||||
|
||||
MIT
|
||||
|
21
bun.lock
21
bun.lock
@ -4,7 +4,8 @@
|
||||
"": {
|
||||
"name": "context7-mcp",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.8.0",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"commander": "^14.0.0",
|
||||
"zod": "^3.24.2",
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -47,7 +48,7 @@
|
||||
|
||||
"@humanwhocodes/retry": ["@humanwhocodes/retry@0.4.2", "", {}, "sha512-xeO57FpIu4p1Ri3Jq/EXq4ClRm86dVF2z/+kvFnyqVYRavTZmaFaUBbWCOuuTh0o/g7DSsk6kc2vrS4Vl5oPOQ=="],
|
||||
|
||||
"@modelcontextprotocol/sdk": ["@modelcontextprotocol/sdk@1.8.0", "", { "dependencies": { "content-type": "^1.0.5", "cors": "^2.8.5", "cross-spawn": "^7.0.3", "eventsource": "^3.0.2", "express": "^5.0.1", "express-rate-limit": "^7.5.0", "pkce-challenge": "^4.1.0", "raw-body": "^3.0.0", "zod": "^3.23.8", "zod-to-json-schema": "^3.24.1" } }, "sha512-e06W7SwrontJDHwCawNO5SGxG+nU9AAx+jpHHZqGl/WrDBdWOpvirC+s58VpJTB5QemI4jTRcjWT4Pt3Q1NPQQ=="],
|
||||
"@modelcontextprotocol/sdk": ["@modelcontextprotocol/sdk@1.12.1", "", { "dependencies": { "ajv": "^6.12.6", "content-type": "^1.0.5", "cors": "^2.8.5", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "express": "^5.0.1", "express-rate-limit": "^7.5.0", "pkce-challenge": "^5.0.0", "raw-body": "^3.0.0", "zod": "^3.23.8", "zod-to-json-schema": "^3.24.1" } }, "sha512-KG1CZhZfWg+u8pxeM/mByJDScJSrjjxLc8fwQqbsS8xCjBmQfMNEBTotYdNanKekepnfRI85GtgQlctLFpcYPw=="],
|
||||
|
||||
"@nodelib/fs.scandir": ["@nodelib/fs.scandir@2.1.5", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],
|
||||
|
||||
@ -113,6 +114,8 @@
|
||||
|
||||
"color-name": ["color-name@1.1.4", "", {}, "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="],
|
||||
|
||||
"commander": ["commander@14.0.0", "", {}, "sha512-2uM9rYjPvyq39NwLRqaiLtWHyDC1FvryJDa2ATTVims5YAS4PupsEQsDvP14FqhFr0P49CYDugi59xaxJlTXRA=="],
|
||||
|
||||
"concat-map": ["concat-map@0.0.1", "", {}, "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="],
|
||||
|
||||
"content-disposition": ["content-disposition@1.0.0", "", { "dependencies": { "safe-buffer": "5.2.1" } }, "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg=="],
|
||||
@ -317,7 +320,7 @@
|
||||
|
||||
"picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
|
||||
|
||||
"pkce-challenge": ["pkce-challenge@4.1.0", "", {}, "sha512-ZBmhE1C9LcPoH9XZSdwiPtbPHZROwAnMy+kIFQVrnMCxY4Cudlz3gBOpzilgc0jOgRaiT3sIWfpMomW2ar2orQ=="],
|
||||
"pkce-challenge": ["pkce-challenge@5.0.0", "", {}, "sha512-ueGLflrrnvwB3xuo/uGob5pd5FN7l0MsLf0Z87o/UQmRtwjvfylfc9MurIxRAWywCYTgrvpXBcqjV4OfCYGCIQ=="],
|
||||
|
||||
"prelude-ls": ["prelude-ls@1.2.1", "", {}, "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g=="],
|
||||
|
||||
@ -417,28 +420,16 @@
|
||||
|
||||
"@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="],
|
||||
|
||||
"@eslint/config-array/minimatch": ["minimatch@3.1.2", "", { "dependencies": { "brace-expansion": "^1.1.7" } }, "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw=="],
|
||||
|
||||
"@eslint/eslintrc/minimatch": ["minimatch@3.1.2", "", { "dependencies": { "brace-expansion": "^1.1.7" } }, "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw=="],
|
||||
|
||||
"@humanfs/node/@humanwhocodes/retry": ["@humanwhocodes/retry@0.3.1", "", {}, "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA=="],
|
||||
|
||||
"@typescript-eslint/typescript-estree/minimatch": ["minimatch@9.0.5", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow=="],
|
||||
|
||||
"@typescript-eslint/visitor-keys/eslint-visitor-keys": ["eslint-visitor-keys@4.2.0", "", {}, "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw=="],
|
||||
|
||||
"body-parser/qs": ["qs@6.14.0", "", { "dependencies": { "side-channel": "^1.1.0" } }, "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w=="],
|
||||
|
||||
"espree/eslint-visitor-keys": ["eslint-visitor-keys@4.2.0", "", {}, "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw=="],
|
||||
|
||||
"express/debug": ["debug@4.3.6", "", { "dependencies": { "ms": "2.1.2" } }, "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg=="],
|
||||
|
||||
"fast-glob/glob-parent": ["glob-parent@5.1.2", "", { "dependencies": { "is-glob": "^4.0.1" } }, "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow=="],
|
||||
|
||||
"@eslint/config-array/minimatch/brace-expansion": ["brace-expansion@1.1.11", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA=="],
|
||||
|
||||
"@eslint/eslintrc/minimatch/brace-expansion": ["brace-expansion@1.1.11", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA=="],
|
||||
|
||||
"@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="],
|
||||
|
||||
"express/debug/ms": ["ms@2.1.2", "", {}, "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="],
|
||||
|
321
docs/README.ar.md
Normal file
321
docs/README.ar.md
Normal file
@ -0,0 +1,321 @@
|
||||
# Context7 MCP - توثيق أكواد محدث لأي أمر برمجي
|
||||
|
||||
[](https://context7.com) [](https://smithery.ai/server/@upstash/context7-mcp) [<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
## ❌ بدون Context7
|
||||
|
||||
تعتمد النماذج اللغوية الكبيرة على معلومات قديمة أو عامة حول المكتبات التي تستخدمها. مما يؤدي إلى:
|
||||
|
||||
- ❌ أمثلة أكواد قديمة مبنية على بيانات تدريب مضى عليها وقت طويل
|
||||
- ❌ واجهات برمجة تطبيقات وهمية غير موجودة
|
||||
- ❌ إجابات عامة لنسخ قديمة من الحزم
|
||||
|
||||
## ✅ مع Context7
|
||||
|
||||
يستخرج Context7 MCP التوثيق والأمثلة البرمجية المحدثة مباشرة من المصدر — ويضعها في طلبك للنموذج.
|
||||
|
||||
أضف `use context7` إلى طلبك في Cursor:
|
||||
|
||||
```txt
|
||||
أنشئ مشروع Next.js بسيط باستخدام app router. use context7
|
||||
```
|
||||
|
||||
```txt
|
||||
أنشئ سكربت لحذف الصفوف التي تكون فيها المدينة فارغة "" باستخدام بيانات اعتماد PostgreSQL. use context7
|
||||
```
|
||||
|
||||
يقوم Context7 بجلب الأمثلة المحدثة والتوثيق المناسب مباشرة إلى السياق.
|
||||
|
||||
- 1️⃣ اكتب طلبك بشكل طبيعي
|
||||
- 2️⃣ أخبر النموذج بـ `use context7`
|
||||
- 3️⃣ احصل على أكواد تعمل مباشرة
|
||||
|
||||
لا حاجة للتنقل بين التبويبات، لا واجهات برمجة تطبيقات وهمية، لا أكواد قديمة.
|
||||
|
||||
## 🛠️ البدء
|
||||
|
||||
### المتطلبات
|
||||
|
||||
- Node.js إصدار 18.0.0 أو أعلى
|
||||
- Cursor، Windsurf، Claude Desktop أو أي عميل MCP آخر
|
||||
|
||||
### التثبيت عبر Smithery
|
||||
|
||||
لتثبيت Context7 MCP Server تلقائيًا لـ Claude Desktop:
|
||||
|
||||
```bash
|
||||
npx -y @smithery/cli install @upstash/context7-mcp --client claude
|
||||
```
|
||||
|
||||
### التثبيت في Cursor
|
||||
|
||||
اذهب إلى: `Settings` -> `Cursor Settings` -> `MCP` -> `Add new global MCP server`
|
||||
|
||||
أو أضف هذا إلى ملف `~/.cursor/mcp.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### التثبيت باستخدام Bun
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### التثبيت باستخدام Deno
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "deno",
|
||||
"args": ["run", "--allow-env", "--allow-net", "npm:@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### التثبيت في Windsurf
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### التثبيت في VS Code
|
||||
|
||||
```json
|
||||
{
|
||||
"servers": {
|
||||
"Context7": {
|
||||
"type": "stdio",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### التثبيت في Zed
|
||||
|
||||
```json
|
||||
{
|
||||
"context_servers": {
|
||||
"Context7": {
|
||||
"command": {
|
||||
"path": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
},
|
||||
"settings": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### التثبيت في Claude Code
|
||||
|
||||
```sh
|
||||
claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
|
||||
```
|
||||
|
||||
### التثبيت في Claude Desktop
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### التثبيت في BoltAI
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### باستخدام Docker
|
||||
|
||||
**Dockerfile:**
|
||||
|
||||
```Dockerfile
|
||||
FROM node:18-alpine
|
||||
WORKDIR /app
|
||||
RUN npm install -g @upstash/context7-mcp@latest
|
||||
CMD ["context7-mcp"]
|
||||
```
|
||||
|
||||
**بناء الصورة:**
|
||||
|
||||
```bash
|
||||
docker build -t context7-mcp .
|
||||
```
|
||||
|
||||
**التهيئة داخل العميل:**
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Context7": {
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### التثبيت في Windows
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"github.com/upstash/context7-mcp": {
|
||||
"command": "cmd",
|
||||
"args": ["/c", "npx", "-y", "@upstash/context7-mcp@latest"],
|
||||
"disabled": false,
|
||||
"autoApprove": []
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### المتغيرات البيئية
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"],
|
||||
"env": {
|
||||
"DEFAULT_MINIMUM_TOKENS": "10000"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### الأدوات المتوفرة
|
||||
|
||||
- `resolve-library-id`: يحول اسم مكتبة عام إلى معرف متوافق مع Context7.
|
||||
- `get-library-docs`: يستخرج التوثيق حسب المعرف.
|
||||
|
||||
- `context7CompatibleLibraryID`: مطلوب
|
||||
- `topic`: موضوع معين مثل "routing"
|
||||
- `tokens`: الحد الأعلى لعدد الرموز
|
||||
|
||||
## التطوير
|
||||
|
||||
```bash
|
||||
bun i
|
||||
bun run build
|
||||
```
|
||||
|
||||
**التهيئة المحلية:**
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["tsx", "/path/to/folder/context7-mcp/src/index.ts"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**الاختبار باستخدام MCP Inspector:**
|
||||
|
||||
```bash
|
||||
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
|
||||
```
|
||||
|
||||
## استكشاف الأخطاء
|
||||
|
||||
### ERR_MODULE_NOT_FOUND
|
||||
|
||||
استخدم `bunx` بدلاً من `npx`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### مشاكل في ESM
|
||||
|
||||
جرّب إضافة:
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "npx",
|
||||
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/context7-mcp@1.0.6"]
|
||||
}
|
||||
```
|
||||
|
||||
### أخطاء عميل MCP
|
||||
|
||||
1. أزل `@latest`
|
||||
2. جرّب `bunx`
|
||||
3. جرّب `deno`
|
||||
4. تأكد أنك تستخدم Node v18 أو أحدث
|
||||
|
||||
## إخلاء مسؤولية
|
||||
|
||||
المشاريع المدرجة في Context7 مساهم بها من المجتمع، ولا يمكن ضمان دقتها أو أمانها بشكل كامل. الرجاء الإبلاغ عن أي محتوى مريب باستخدام زر "الإبلاغ".
|
||||
|
||||
## Context7 في الإعلام
|
||||
|
||||
- [Better Stack: "أداة مجانية تجعل Cursor أذكى 10x"](https://youtu.be/52FC3qObp9E)
|
||||
- [Cole Medin: "أفضل MCP Server لمساعدين الذكاء الاصطناعي البرمجيين"](https://www.youtube.com/watch?v=G7gK8H6u7Rs)
|
||||
- [Context7 + SequentialThinking: هل هذا AGI؟](https://www.youtube.com/watch?v=-ggvzyLpK6o)
|
||||
- [تحديث جديد من Context7 MCP](https://www.youtube.com/watch?v=CTZm6fBYisc)
|
||||
- [إعداد Context7 في VS Code](https://www.youtube.com/watch?v=-ls0D-rtET4)
|
||||
- [Context7: MCP جديد سيغير البرمجة](https://www.youtube.com/watch?v=PS-2Azb-C3M)
|
||||
- [Cline & RooCode + Context7: قوة مضاعفة](https://www.youtube.com/watch?v=qZfENAPMnyo)
|
||||
- [أفضل 5 MCP Servers لتجربة برمجة ساحرة](https://www.youtube.com/watch?v=LqTQi8qexJM)
|
||||
|
||||
## سجل النجوم
|
||||
|
||||
[](https://www.star-history.com/#upstash/context7&Date)
|
||||
|
||||
## الترخيص
|
||||
|
||||
MIT
|
@ -209,15 +209,15 @@ Wenn du den MCP-Server lieber in einem Docker-Container ausführen möchtest:
|
||||
|
||||
Aktualisiere die Konfiguration deines MCP-Clients, um den Docker-Befehl zu verwenden.
|
||||
|
||||
*Beispiel für eine cline_mcp_settings.json:*
|
||||
_Beispiel für eine cline_mcp_settings.json:_
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
@ -225,7 +225,8 @@ Wenn du den MCP-Server lieber in einem Docker-Container ausführen möchtest:
|
||||
}
|
||||
}
|
||||
```
|
||||
*Hinweis: Dies ist eine Beispielkonfiguration. Bitte beziehe dich auf die spezifischen Beispiele für deinen MCP-Client (wie Cursor, VS Code usw.), die weiter oben in dieser README beschrieben sind, um die Struktur anzupassen (z.B. `mcpServers` vs `servers`). Stelle außerdem sicher, dass der Bildname in `args` mit dem beim `docker build`-Befehl verwendeten Tag übereinstimmt.*
|
||||
|
||||
_Hinweis: Dies ist eine Beispielkonfiguration. Bitte beziehe dich auf die spezifischen Beispiele für deinen MCP-Client (wie Cursor, VS Code usw.), die weiter oben in dieser README beschrieben sind, um die Struktur anzupassen (z.B. `mcpServers` vs `servers`). Stelle außerdem sicher, dass der Bildname in `args` mit dem beim `docker build`-Befehl verwendeten Tag übereinstimmt._
|
||||
|
||||
### Verfügbare Tools
|
||||
|
||||
@ -297,11 +298,7 @@ Wenn du einen Fehler wie `Error: Cannot find module 'uriTemplate.js'` bekommst,
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"--node-options=--experimental-vm-modules",
|
||||
"@upstash/context7-mcp@1.0.6"
|
||||
]
|
||||
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/context7-mcp@1.0.6"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -318,6 +315,7 @@ Wenn du einen Fehler wie `Error: Cannot find module 'uriTemplate.js'` bekommst,
|
||||
4. Stelle sicher, dass du Node v18 oder höher verwendest, um native Fetch-Unterstützung mit `npx` zu haben.
|
||||
|
||||
## Haftungsausschluss
|
||||
|
||||
Context7-Projekte werden von der Community beigetragen, und obwohl wir uns bemühen, eine hohe Qualität aufrechtzuerhalten, können wir die Genauigkeit, Vollständigkeit oder Sicherheit aller Bibliotheksdokumentationen nicht garantieren. Die in Context7 aufgeführten Projekte werden von ihren jeweiligen Eigentümern entwickelt und gepflegt, nicht von Context7. Wenn du auf verdächtige, unangemessene oder potenziell schädliche Inhalte stößt, verwende bitte die Schaltfläche "Melden" auf der Projektseite, um uns sofort zu benachrichtigen. Wir nehmen alle Berichte ernst und werden gemeldete Inhalte umgehend überprüfen, um die Integrität und Sicherheit unserer Plattform zu gewährleisten. Durch die Nutzung von Context7 erkennst du an, dass du dies nach eigenem Ermessen und auf eigenes Risiko tust.
|
||||
|
||||
## Context7 in den Medien
|
||||
@ -335,4 +333,4 @@ Context7-Projekte werden von der Community beigetragen, und obwohl wir uns bemü
|
||||
|
||||
## Lizenz
|
||||
|
||||
MIT
|
||||
MIT
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Context7 MCP - Documentation à jour pour vos prompts
|
||||
|
||||
[](https://context7.com) [](https://smithery.ai/server/@upstash/context7-mcp)[<img alt="Installer dans VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Installer%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522context7%2522%252C%2522config%2522%253A%257B%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522-y%2522%252C%2522%2540upstash%252Fcontext7-mcp%2540latest%2522%255D%257D%257D)
|
||||
[](https://context7.com) [](https://smithery.ai/server/@upstash/context7-mcp) [<img alt="Installer dans VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Installer%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
## ❌ Sans Context7
|
||||
|
||||
@ -113,10 +113,10 @@ Ajoutez ceci à votre fichier de configuration MCP Windsurf. Voir la [documentat
|
||||
|
||||
### Installation dans VS Code
|
||||
|
||||
[<img alt="Installation dans VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Installer%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522context7%2522%252C%2522config%2522%253A%257B%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522-y%2522%252C%2522%2540upstash%252Fcontext7-mcp%2540latest%2522%255D%257D%257D)
|
||||
[<img alt="Installation dans VS Code Insiders (npx)" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Installer%20Context7%20MCP&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522context7%2522%252C%2522config%2522%253A%257B%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522-y%2522%252C%2522%2540upstash%252Fcontext7-mcp%2540latest%2522%255D%257D%257D)
|
||||
[<img alt="Installer dans VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Installer%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
[<img alt="Installer dans VS Code Insiders (npx)" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Installer%20Context7%20MCP&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
Ajoutez ceci à votre fichier de configuration MCP VS Code. Voir la [documentation VS Code MCP](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) pour plus d’informations.
|
||||
Ajoutez ceci à votre fichier de configuration MCP VS Code. Voir la [documentation VS Code MCP](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) pour plus d'informations.
|
||||
|
||||
```json
|
||||
{
|
||||
@ -171,6 +171,23 @@ Ajoutez ceci à votre fichier `claude_desktop_config.json`. Voir la [documentati
|
||||
}
|
||||
```
|
||||
|
||||
### Installation dans BoltAI
|
||||
|
||||
Ouvrez la page "Settings" de l'application, naviguez jusqu'à "Plugins", et entrez le JSON suivant :
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Une fois enregistré, saisissez dans le chat `get-library-docs` suivi de votre ID de documentation Context7 (par exemple, `get-library-docs /nuxt/ui`). Plus d'informations sont disponibles sur le [site de documentation BoltAI](https://docs.boltai.com/docs/plugins/mcp-servers). Pour BoltAI sur iOS, [consultez ce guide](https://docs.boltai.com/docs/boltai-mobile/mcp-servers).
|
||||
|
||||
### Utilisation avec Docker
|
||||
|
||||
Si vous préférez exécuter le serveur MCP dans un conteneur Docker :
|
||||
@ -209,15 +226,15 @@ Si vous préférez exécuter le serveur MCP dans un conteneur Docker :
|
||||
|
||||
Mettez à jour la configuration de votre client MCP pour utiliser la commande Docker.
|
||||
|
||||
*Exemple pour un fichier cline_mcp_settings.json :*
|
||||
_Exemple pour un fichier cline_mcp_settings.json :_
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
@ -225,7 +242,45 @@ Si vous préférez exécuter le serveur MCP dans un conteneur Docker :
|
||||
}
|
||||
}
|
||||
```
|
||||
*Note : Ceci est un exemple. Adaptez la structure selon votre client MCP (voir plus haut dans ce README). Assurez-vous que le nom de l’image dans `args` correspond au tag utilisé lors du build.*
|
||||
|
||||
_Note : Ceci est un exemple. Adaptez la structure selon votre client MCP (voir plus haut dans ce README). Assurez-vous que le nom de l’image dans `args` correspond au tag utilisé lors du build._
|
||||
|
||||
### Installation sous Windows
|
||||
|
||||
La configuration sous Windows est légèrement différente par rapport à Linux ou macOS (_`Cline` est utilisé dans l'exemple_). Le même principe s'applique à d'autres éditeurs; référez-vous à la configuration de `command` et `args`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"github.com/upstash/context7-mcp": {
|
||||
"command": "cmd",
|
||||
"args": ["/c", "npx", "-y", "@upstash/context7-mcp@latest"],
|
||||
"disabled": false,
|
||||
"autoApprove": []
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Variables d'environnement
|
||||
|
||||
- `DEFAULT_MINIMUM_TOKENS`: Définissez le nombre minimum de tokens pour la récupération de documentation (par défaut: 10000).
|
||||
|
||||
Exemples:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"],
|
||||
"env": {
|
||||
"DEFAULT_MINIMUM_TOKENS": "10000"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Outils disponibles
|
||||
|
||||
@ -288,11 +343,31 @@ Si vous voyez cette erreur, essayez d’utiliser `bunx` à la place de `npx`.
|
||||
|
||||
Cela résout souvent les problèmes de résolution de modules, surtout si `npx` n’installe ou ne résout pas correctement les packages.
|
||||
|
||||
### Problèmes de résolution ESM
|
||||
|
||||
Si vous rencontrez une erreur comme : `Error: Cannot find module 'uriTemplate.js'` essayez d'exécuter avec le drapeau `--experimental-vm-modules` :
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/context7-mcp@1.0.6"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Erreurs client MCP
|
||||
|
||||
1. Essayez de retirer `@latest` du nom du package.
|
||||
2. Essayez d’utiliser `bunx` comme alternative.
|
||||
3. Essayez d’utiliser `deno` comme alternative.
|
||||
2. Essayez d'utiliser `bunx` comme alternative.
|
||||
3. Essayez d'utiliser `deno` comme alternative.
|
||||
4. Assurez-vous d'utiliser Node v18 ou supérieur pour avoir le support natif de fetch avec `npx`.
|
||||
|
||||
## Clause de non-responsabilité
|
||||
|
||||
Les projets Context7 sont des contributions de la communauté, et bien que nous nous efforcions de maintenir une haute qualité, nous ne pouvons garantir l'exactitude, l'exhaustivité ou la sécurité de toute la documentation des bibliothèques. Les projets listés dans Context7 sont développés et maintenus par leurs propriétaires respectifs, et non par Context7. Si vous rencontrez un contenu suspect, inapproprié ou potentiellement nuisible, veuillez utiliser le bouton "Signaler" sur la page du projet pour nous le faire savoir immédiatement. Nous prenons tous les signalements au sérieux et examinerons rapidement les contenus signalés pour maintenir l'intégrité et la sécurité de notre plateforme. En utilisant Context7, vous reconnaissez que vous le faites à votre propre discrétion et à vos risques et périls.
|
||||
|
||||
## Context7 dans les médias
|
||||
|
||||
@ -302,6 +377,8 @@ Cela résout souvent les problèmes de résolution de modules, surtout si `npx`
|
||||
- [Julian Goldie SEO: "Context7: New MCP AI Agent Update"](https://www.youtube.com/watch?v=CTZm6fBYisc)
|
||||
- [JeredBlu: "Context 7 MCP: Get Documentation Instantly + VS Code Setup"](https://www.youtube.com/watch?v=-ls0D-rtET4)
|
||||
- [Income stream surfers: "Context7: The New MCP Server That Will CHANGE AI Coding"](https://www.youtube.com/watch?v=PS-2Azb-C3M)
|
||||
- [AICodeKing: "Context7 + Cline & RooCode: This MCP Server Makes CLINE 100X MORE EFFECTIVE!"](https://www.youtube.com/watch?v=qZfENAPMnyo)
|
||||
- [Sean Kochel: "5 MCP Servers For Vibe Coding Glory (Just Plug-In & Go)"](https://www.youtube.com/watch?v=LqTQi8qexJM)
|
||||
|
||||
## Historique des stars
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
|
||||
# Context7 MCP - Dokumentasi Ter-Update Untuk Setiap Prompt
|
||||
|
||||
[](https://context7.com) [](https://smithery.ai/server/@upstash/context7-mcp) [<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
[](./README.zh-CN.md) [](./README.ko.md) [](./README.es.md) [](./README.fr.md) [-purple)](./README.pt-BR.md) [](./README.id-ID.md)
|
||||
[](./README.zh-CN.md) [](./README.ko.md) [](./README.es.md) [](./README.fr.md) [-purple>)](./README.pt-BR.md) [](./README.id-ID.md)
|
||||
|
||||
## ❌ Tanpa Context7
|
||||
|
||||
LLM mengandalkan informasi yang sudah lama atau umum tentang library yang Anda gunakan, bukan yang terbaru.
|
||||
LLM mengandalkan informasi yang sudah lama atau umum tentang library yang Anda gunakan, bukan yang terbaru.
|
||||
|
||||
Hasilnya anda akan mendapatkan:
|
||||
|
||||
- ❌ Contoh kode sudah usang dan berdasarkan data pelatihan yang sudah lama
|
||||
- ❌ API yang dikarang yang sebetulnya tidak ada sama sekali
|
||||
- ❌ Jawaban umum untuk versi paket lama
|
||||
@ -213,15 +213,15 @@ Jika Anda lebih suka menjalankan server MCP dalam kontainer Docker:
|
||||
|
||||
Perbarui konfigurasi MCP client Anda untuk menggunakan perintah Docker.
|
||||
|
||||
*Contoh untuk cline_mcp_settings.json:*
|
||||
_Contoh untuk cline_mcp_settings.json:_
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
@ -229,7 +229,8 @@ Jika Anda lebih suka menjalankan server MCP dalam kontainer Docker:
|
||||
}
|
||||
}
|
||||
```
|
||||
*Catatan: Ini adalah contoh konfigurasi. Silakan merujuk ke contoh spesifik untuk MCP client Anda (seperti Cursor, VS Code, dll.) sebelumnya dalam README ini untuk menyesuaikan struktur (misalnya, `mcpServers` vs `servers`). Juga, pastikan nama image di `args` cocok dengan tag yang digunakan selama perintah `docker build`.*
|
||||
|
||||
_Catatan: Ini adalah contoh konfigurasi. Silakan merujuk ke contoh spesifik untuk MCP client Anda (seperti Cursor, VS Code, dll.) sebelumnya dalam README ini untuk menyesuaikan struktur (misalnya, `mcpServers` vs `servers`). Juga, pastikan nama image di `args` cocok dengan tag yang digunakan selama perintah `docker build`._
|
||||
|
||||
### Alat yang Tersedia
|
||||
|
||||
@ -301,11 +302,7 @@ Jika Anda mengalami kesalahan seperti: `Error: Cannot find module 'uriTemplate.j
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"--node-options=--experimental-vm-modules",
|
||||
"@upstash/context7-mcp@1.0.6"
|
||||
]
|
||||
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/context7-mcp@1.0.6"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -322,6 +319,7 @@ Jika Anda mengalami kesalahan seperti: `Error: Cannot find module 'uriTemplate.j
|
||||
4. Pastikan Anda menggunakan Node v18 atau lebih tinggi untuk memiliki dukungan fetch native dengan `npx`.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
Proyek Context7 adalah kontribusi komunitas dan meskipun kami berusaha untuk mempertahankan kualitas tinggi, kami tidak dapat menjamin keakuratan, kelengkapan, atau keamanan semua dokumentasi library. Proyek yang terdaftar di Context7 dikembangkan dan dikelola oleh pemiliknya masing-masing, bukan oleh Context7. Jika Anda menemukan konten yang mencurigakan, tidak pantas, atau berpotensi berbahaya, silakan gunakan tombol "Report" di halaman proyek untuk memberi tahu kami segera. Kami menganggap semua laporan dengan serius dan akan meninjau konten yang ditandai segera untuk menjaga integritas dan keamanan platform kami. Dengan menggunakan Context7, Anda mengakui bahwa Anda melakukannya atas kebijaksanaan dan risiko Anda sendiri.
|
||||
|
||||
## Context7 Di Media
|
||||
@ -340,4 +338,3 @@ Proyek Context7 adalah kontribusi komunitas dan meskipun kami berusaha untuk mem
|
||||
## Lisensi
|
||||
|
||||
MIT
|
||||
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
[](https://context7.com) [](https://smithery.ai/server/@upstash/context7-mcp) [<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Installa%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
[](./docs/README.zh-CN.md) [](./docs/README.ko.md) [](./docs/README.es.md) [](./docs/README.fr.md) [-purple)](./docs/README.pt-BR.md) [](./docs/README.it.md)
|
||||
|
||||
[](./docs/README.zh-CN.md) [](./docs/README.ko.md) [](./docs/README.es.md) [](./docs/README.fr.md) [-purple>)](./docs/README.pt-BR.md) [](./docs/README.it.md)
|
||||
|
||||
## ❌ Senza Context7
|
||||
|
||||
@ -212,15 +211,15 @@ Se preferisci eseguire il server MCP in un contenitore Docker:
|
||||
|
||||
Aggiorna la configurazione del tuo client MCP per utilizzare il comando Docker.
|
||||
|
||||
*Esempio per un file cline_mcp_settings.json:*
|
||||
_Esempio per un file cline_mcp_settings.json:_
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
@ -228,7 +227,8 @@ Se preferisci eseguire il server MCP in un contenitore Docker:
|
||||
}
|
||||
}
|
||||
```
|
||||
*Nota: Questa è una configurazione di esempio. Consulta gli esempi specifici per il tuo client MCP (come Cursor, VS Code, ecc.) precedentemente in questo README per adattare la struttura (ad es., `mcpServers` vs `servers`). Inoltre, assicurati che il nome dell'immagine in `args` corrisponda al tag utilizzato durante il comando `docker build`.*
|
||||
|
||||
_Nota: Questa è una configurazione di esempio. Consulta gli esempi specifici per il tuo client MCP (come Cursor, VS Code, ecc.) precedentemente in questo README per adattare la struttura (ad es., `mcpServers` vs `servers`). Inoltre, assicurati che il nome dell'immagine in `args` corrisponda al tag utilizzato durante il comando `docker build`._
|
||||
|
||||
### Strumenti Disponibili
|
||||
|
||||
@ -252,6 +252,7 @@ Compila:
|
||||
```bash
|
||||
bun run build
|
||||
```
|
||||
|
||||
### Esempio di Configurazione Locale
|
||||
|
||||
```json
|
||||
@ -299,11 +300,7 @@ Se riscontri un errore come: `Error: Cannot find module 'uriTemplate.js'` prova
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"--node-options=--experimental-vm-modules",
|
||||
"@upstash/context7-mcp@1.0.6"
|
||||
]
|
||||
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/context7-mcp@1.0.6"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -320,6 +317,7 @@ Se riscontri un errore come: `Error: Cannot find module 'uriTemplate.js'` prova
|
||||
4. Assicurati di utilizzare Node v18 o superiore per avere il supporto nativo di fetch con `npx`.
|
||||
|
||||
## Dichiarazione di non responsabilità
|
||||
|
||||
I progetti Context7 sono contributi della comunità e, sebbene ci impegniamo a mantenere un'alta qualità, non possiamo garantire l'accuratezza, la completezza o la sicurezza di tutta la documentazione delle librerie. I progetti elencati in Context7 sono sviluppati e gestiti dai rispettivi proprietari, non da Context7. Se riscontri contenuti sospetti, inappropriati o potenzialmente dannosi, utilizza il pulsante "Segnala" sulla pagina del progetto per informarci immediatamente. Prendiamo sul serio tutte le segnalazioni e esamineremo prontamente i contenuti segnalati per mantenere l'integrità e la sicurezza della nostra piattaforma. Utilizzando Context7, riconosci di farlo a tua discrezione e a tuo rischio.
|
||||
|
||||
## Context7 nei Media
|
||||
|
690
docs/README.ja.md
Normal file
690
docs/README.ja.md
Normal file
@ -0,0 +1,690 @@
|
||||
# Context7 MCP - どんなプロンプトにも最新のコードドキュメントで応える
|
||||
|
||||
[](https://context7.com) [](https://smithery.ai/server/@upstash/context7-mcp) [<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
[](./docs/README.zh-TW.md) [](./docs/README.zh-CN.md) [](./docs/README.ja.md) [](./docs/README.ko.md) [](./docs/README.es.md) [](./docs/README.fr.md) [-purple>)](./docs/README.pt-BR.md) [](./docs/README.it.md) [](./docs/README.id-ID.md) [](./docs/README.de.md) [](./docs/README.ru.md) [](./docs/README.tr.md) [](./docs/README.ar.md)
|
||||
|
||||
## ❌ Context7 を使わないと
|
||||
|
||||
LLM は使用しているライブラリに関する古い情報や一般的な情報に依存しています。その結果:
|
||||
|
||||
- ❌ コード例が古く、1 年前のトレーニングデータに基づいている
|
||||
- ❌ 存在しない API をハルシネーションして生成する
|
||||
- ❌ 古いパッケージバージョンに対する一般的な回答しか得られない
|
||||
|
||||
## ✅ Context7 を使うと
|
||||
|
||||
Context7 MCP は最新のバージョン固有のドキュメントとコード例をソースから直接取得し、プロンプトに直接配置します。
|
||||
|
||||
Cursor のプロンプトに `use context7` を追加するだけ:
|
||||
|
||||
```txt
|
||||
Create a basic Next.js project with app router. use context7
|
||||
```
|
||||
|
||||
```txt
|
||||
Create a script to delete the rows where the city is "" given PostgreSQL credentials. use context7
|
||||
```
|
||||
|
||||
Context7 は最新のコード例とドキュメントを直接 LLM のコンテキストに取得します。
|
||||
|
||||
- 1️⃣ 普段通りにプロンプトを書く
|
||||
- 2️⃣ LLM に `use context7` と指示する
|
||||
- 3️⃣ 動作するコードの回答を得る
|
||||
|
||||
タブの切り替えも、存在しない API のハルシネーションも、古いコード生成もありません。
|
||||
|
||||
## 📚 プロジェクトの追加
|
||||
|
||||
[プロジェクト追加ガイド](./docs/adding-projects.md) をチェックして、お気に入りのライブラリを Context7 に追加(または更新)する方法を学びましょう。
|
||||
|
||||
## 🛠️ インストール
|
||||
|
||||
### 必須要件
|
||||
|
||||
- Node.js >= v18.0.0
|
||||
- Cursor、Windsurf、Claude Desktop またはその他の MCP クライアント
|
||||
|
||||
<details>
|
||||
<summary><b>Smithery 経由でのインストール</b></summary>
|
||||
|
||||
[Smithery](https://smithery.ai/server/@upstash/context7-mcp) 経由で任意のクライアントに Context7 MCP サーバーを自動的にインストールするには:
|
||||
|
||||
```bash
|
||||
npx -y @smithery/cli@latest install @upstash/context7-mcp --client <CLIENT_NAME> --key <YOUR_SMITHERY_KEY>
|
||||
```
|
||||
|
||||
Smithery キーは [Smithery.ai Web ページ](https://smithery.ai/server/@upstash/context7-mcp) で確認できます。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Cursor へのインストール</b></summary>
|
||||
|
||||
`Settings` -> `Cursor Settings` -> `MCP` -> `Add new global MCP server` に移動します
|
||||
|
||||
以下の設定を Cursor の `~/.cursor/mcp.json` ファイルに貼り付けることが推奨されます。プロジェクトフォルダに `.cursor/mcp.json` を作成することで、特定のプロジェクトにインストールすることもできます。詳細は [Cursor MCP ドキュメント](https://docs.cursor.com/context/model-context-protocol) を参照してください。
|
||||
|
||||
> Cursor 1.0 以降、下のインストールボタンをクリックすることで、ワンクリックで即座にインストールできます。
|
||||
|
||||
#### Cursor リモートサーバー接続
|
||||
|
||||
[](https://cursor.com/install-mcp?name=context7&config=eyJ1cmwiOiJodHRwczovL21jcC5jb250ZXh0Ny5jb20vbWNwIn0%3D)
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Cursor ローカルサーバー接続
|
||||
|
||||
[](https://cursor.com/install-mcp?name=context7&config=eyJjb21tYW5kIjoibnB4IC15IEB1cHN0YXNoL2NvbnRleHQ3LW1jcCJ9)
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>代替方法:Bun を使用</summary>
|
||||
|
||||
[](https://cursor.com/install-mcp?name=context7&config=eyJjb21tYW5kIjoiYnVueCAteSBAdXBzdGFzaC9jb250ZXh0Ny1tY3AifQ%3D%3D)
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>代替方法:Deno を使用</summary>
|
||||
|
||||
[](https://cursor.com/install-mcp?name=context7&config=eyJjb21tYW5kIjoiZGVubyBydW4gLS1hbGxvdy1lbnYgLS1hbGxvdy1uZXQgbnBtOkB1cHN0YXNoL2NvbnRleHQ3LW1jcCJ9)
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "deno",
|
||||
"args": ["run", "--allow-env=NO_DEPRECATION,TRACE_DEPRECATION", "--allow-net", "npm:@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Windsurf へのインストール</b></summary>
|
||||
|
||||
これを Windsurf MCP 設定ファイルに追加します。詳細は [Windsurf MCP ドキュメント](https://docs.windsurf.com/windsurf/mcp) を参照してください。
|
||||
|
||||
#### Windsurf リモートサーバー接続
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"serverUrl": "https://mcp.context7.com/sse"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Windsurf ローカルサーバー接続
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>VS Code へのインストール</b></summary>
|
||||
|
||||
[<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
[<img alt="Install in VS Code Insiders (npx)" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Install%20Context7%20MCP&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
これを VS Code MCP 設定ファイルに追加します。詳細は [VS Code MCP ドキュメント](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) を参照してください。
|
||||
|
||||
#### VS Code リモートサーバー接続
|
||||
|
||||
```json
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"context7": {
|
||||
"type": "http",
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### VS Code ローカルサーバー接続
|
||||
|
||||
```json
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"context7": {
|
||||
"type": "stdio",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Visual Studio 2022 へのインストール</b></summary>
|
||||
|
||||
[Visual Studio MCP サーバードキュメント](https://learn.microsoft.com/visualstudio/ide/mcp-servers?view=vs-2022) に従って、Visual Studio 2022 で Context7 MCP を設定できます。
|
||||
|
||||
これを Visual Studio MCP 設定ファイルに追加します(詳細は [Visual Studio ドキュメント](https://learn.microsoft.com/visualstudio/ide/mcp-servers?view=vs-2022) を参照):
|
||||
|
||||
```json
|
||||
{
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"context7": {
|
||||
"type": "http",
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
または、ローカルサーバーの場合:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"context7": {
|
||||
"type": "stdio",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
詳細情報とトラブルシューティングについては、[Visual Studio MCP サーバードキュメント](https://learn.microsoft.com/visualstudio/ide/mcp-servers?view=vs-2022) を参照してください。
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Zed へのインストール</b></summary>
|
||||
|
||||
[Zed Extensions](https://zed.dev/extensions?query=Context7) 経由でインストールできるか、Zed の `settings.json` にこれを追加できます。詳細は [Zed Context Server ドキュメント](https://zed.dev/docs/assistant/context-servers) を参照してください。
|
||||
|
||||
```json
|
||||
{
|
||||
"context_servers": {
|
||||
"Context7": {
|
||||
"command": {
|
||||
"path": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
},
|
||||
"settings": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Claude Code へのインストール</b></summary>
|
||||
|
||||
このコマンドを実行します。詳細は [Claude Code MCP ドキュメント](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#set-up-model-context-protocol-mcp) を参照してください。
|
||||
|
||||
#### Claude Code リモートサーバー接続
|
||||
|
||||
```sh
|
||||
claude mcp add --transport sse context7 https://mcp.context7.com/sse
|
||||
```
|
||||
|
||||
#### Claude Code ローカルサーバー接続
|
||||
|
||||
```sh
|
||||
claude mcp add context7 -- npx -y @upstash/context7-mcp
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Claude Desktop へのインストール</b></summary>
|
||||
|
||||
これを Claude Desktop の `claude_desktop_config.json` ファイルに追加します。詳細は [Claude Desktop MCP ドキュメント](https://modelcontextprotocol.io/quickstart/user) を参照してください。
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>BoltAI へのインストール</b></summary>
|
||||
|
||||
アプリの "Settings" ページを開き、"Plugins" に移動し、以下の JSON を入力します:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
保存後、チャットで `get-library-docs` の後に Context7 ドキュメント ID を入力します(例:`get-library-docs /nuxt/ui`)。詳細情報は [BoltAI ドキュメンテーションサイト](https://docs.boltai.com/docs/plugins/mcp-servers) で利用可能です。iOS 版 BoltAI については、[このガイドを参照してください](https://docs.boltai.com/docs/boltai-mobile/mcp-servers)。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Docker を使用</b></summary>
|
||||
|
||||
MCP サーバーを Docker コンテナで実行したい場合:
|
||||
|
||||
1. **Docker イメージのビルド:**
|
||||
|
||||
まず、プロジェクトルート(または希望の場所)に `Dockerfile` を作成します:
|
||||
|
||||
<details>
|
||||
<summary>Dockerfile の内容を表示</summary>
|
||||
|
||||
```Dockerfile
|
||||
FROM node:18-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 最新バージョンをグローバルにインストール
|
||||
RUN npm install -g @upstash/context7-mcp
|
||||
|
||||
# 必要に応じてデフォルトポートを公開(任意、MCP クライアントの相互作用に依存)
|
||||
# EXPOSE 3000
|
||||
|
||||
# サーバーを実行するデフォルトコマンド
|
||||
CMD ["context7-mcp"]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
次に、タグ(例:`context7-mcp`)を使用してイメージをビルドします。**Docker Desktop(または Docker デーモン)が実行中であることを確認してください。** `Dockerfile` を保存した同じディレクトリで次のコマンドを実行します:
|
||||
|
||||
```bash
|
||||
docker build -t context7-mcp .
|
||||
```
|
||||
|
||||
2. **MCP クライアントの設定:**
|
||||
|
||||
MCP クライアントの設定を更新して Docker コマンドを使用するようにします。
|
||||
|
||||
_cline_mcp_settings.json の例:_
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
_注:これは設定例です。この README の前半で MCP クライアント(Cursor、VS Code など)の具体的な例を参照して、構造(例:`mcpServers` 対 `servers`)を適応させてください。また、`args` 内のイメージ名が `docker build` コマンドで使用したタグと一致していることを確認してください。_
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Windows へのインストール</b></summary>
|
||||
|
||||
Windows での設定は Linux や macOS と比べて少し異なります(_例では `Cline` を使用_)。同じ原則が他のエディタにも適用されます。`command` と `args` の設定を参照してください。
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"github.com/upstash/context7-mcp": {
|
||||
"command": "cmd",
|
||||
"args": ["/c", "npx", "-y", "@upstash/context7-mcp@latest"],
|
||||
"disabled": false,
|
||||
"autoApprove": []
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Augment Code へのインストール</b></summary>
|
||||
|
||||
Augment Code で Context7 MCP を設定するには、グラフィカルインターフェースまたは手動設定のいずれかを使用できます。
|
||||
|
||||
### **A. Augment Code UI を使用する場合**
|
||||
|
||||
1. ハンバーガーメニューをクリックします。
|
||||
2. **Settings** を選択します。
|
||||
3. **Tools** セクションに移動します。
|
||||
4. **+ Add MCP** ボタンをクリックします。
|
||||
5. 以下のコマンドを入力します:
|
||||
|
||||
```
|
||||
npx -y @upstash/context7-mcp@latest
|
||||
```
|
||||
|
||||
6. MCP に **Context7** と名前を付けます。
|
||||
7. **Add** ボタンをクリックします。
|
||||
|
||||
MCP サーバーが追加されたら、Augment Code 内で Context7 の最新コードドキュメンテーション機能を直接使用できます。
|
||||
|
||||
---
|
||||
|
||||
### **B. 手動設定**
|
||||
|
||||
1. Cmd/Ctrl Shift P を押すか、Augment パネルのハンバーガーメニューに移動します
|
||||
2. Edit Settings を選択します
|
||||
3. Advanced の下で、Edit in settings.json をクリックします
|
||||
4. `augment.advanced` オブジェクト内の `mcpServers` 配列にサーバー設定を追加します
|
||||
|
||||
"augment.advanced": {
|
||||
"mcpServers": [
|
||||
{
|
||||
"name": "context7",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
MCP サーバーが追加されたら、エディタを再起動します。エラーが発生した場合は、構文をチェックして、閉じ括弧やカンマが欠けていないことを確認してください。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Roo Code へのインストール</b></summary>
|
||||
|
||||
これを Roo Code MCP 設定ファイルに追加します。詳細は [Roo Code MCP ドキュメント](https://docs.roocode.com/features/mcp/using-mcp-in-roo) を参照してください。
|
||||
|
||||
#### Roo Code リモートサーバー接続
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"type": "streamable-http",
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Roo Code ローカルサーバー接続
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Zencoder へのインストール</b></summary>
|
||||
|
||||
Zencoder で Context7 MCP を設定するには、以下の手順に従います:
|
||||
|
||||
1. Zencoder メニュー (...) に移動します
|
||||
2. ドロップダウンメニューから Agent tools を選択します
|
||||
3. Add custom MCP をクリックします
|
||||
4. 以下から名前とサーバー設定を追加し、Install ボタンを必ず押してください
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"@upstash/context7-mcp@latest"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
MCP サーバーが追加されたら、簡単に使用を続けることができます。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Amazon Q Developer CLI へのインストール</b></summary>
|
||||
|
||||
これを Amazon Q Developer CLI 設定ファイルに追加します。詳細は [Amazon Q Developer CLI ドキュメント](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-configuration.html) を参照してください。
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
## 🔨 利用可能なツール
|
||||
|
||||
Context7 MCP は LLM が使用できる以下のツールを提供します:
|
||||
|
||||
- `resolve-library-id`:一般的なライブラリ名を Context7 互換のライブラリ ID に変換します。
|
||||
|
||||
- `libraryName`(必須):検索するライブラリの名前
|
||||
|
||||
- `get-library-docs`:Context7 互換のライブラリ ID を使用してライブラリのドキュメントを取得します。
|
||||
- `context7CompatibleLibraryID`(必須):正確な Context7 互換のライブラリ ID(例:`/mongodb/docs`、`/vercel/next.js`)
|
||||
- `topic`(任意):ドキュメントの特定のトピックに焦点を当てます(例:"routing"、"hooks")
|
||||
- `tokens`(任意、デフォルト 10000):返すトークンの最大数。デフォルト値 10000 未満の値は自動的に 10000 に増加されます。
|
||||
|
||||
## 💻 開発
|
||||
|
||||
プロジェクトをクローンして依存関係をインストールします:
|
||||
|
||||
```bash
|
||||
bun i
|
||||
```
|
||||
|
||||
ビルド:
|
||||
|
||||
```bash
|
||||
bun run build
|
||||
```
|
||||
|
||||
サーバーを実行:
|
||||
|
||||
```bash
|
||||
bun run dist/index.js
|
||||
```
|
||||
|
||||
### CLI 引数
|
||||
|
||||
`context7-mcp` は以下の CLI フラグを受け付けます:
|
||||
|
||||
- `--transport <stdio|http|sse>` – 使用するトランスポート(デフォルトは `stdio`)。
|
||||
- `--port <number>` – `http` または `sse` トランスポート使用時にリッスンするポート(デフォルト `3000`)。
|
||||
|
||||
http トランスポートとポート 8080 の例:
|
||||
|
||||
```bash
|
||||
bun run dist/index.js --transport http --port 8080
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary><b>ローカル設定例</b></summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["tsx", "/path/to/folder/context7-mcp/src/index.ts"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>MCP Inspector でのテスト</b></summary>
|
||||
|
||||
```bash
|
||||
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## 🚨 トラブルシューティング
|
||||
|
||||
<details>
|
||||
<summary><b>モジュールが見つからないエラー</b></summary>
|
||||
|
||||
`ERR_MODULE_NOT_FOUND` が発生した場合は、`npx` の代わりに `bunx` を使用してみてください:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
これにより、`npx` がパッケージを正しくインストールまたは解決できない環境でのモジュール解決の問題が解決されることがあります。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>ESM 解決の問題</b></summary>
|
||||
|
||||
`Error: Cannot find module 'uriTemplate.js'` のようなエラーの場合は、`--experimental-vm-modules` フラグを試してください:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/context7-mcp@1.0.6"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>TLS/証明書の問題</b></summary>
|
||||
|
||||
TLS 関連の問題を回避するには、`--experimental-fetch` フラグを使用します:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "--node-options=--experimental-fetch", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>一般的な MCP クライアントエラー</b></summary>
|
||||
|
||||
1. パッケージ名に `@latest` を追加してみる
|
||||
2. `npx` の代替として `bunx` を使用する
|
||||
3. 別の代替方法として `deno` の使用を検討する
|
||||
4. ネイティブ fetch サポートのために Node.js v18 以上を使用していることを確認する
|
||||
|
||||
</details>
|
||||
|
||||
## ⚠️ 免責事項
|
||||
|
||||
Context7 プロジェクトはコミュニティが貢献しているもので、高品質を維持するよう努めていますが、すべてのライブラリドキュメントの正確性、完全性、セキュリティを保証することはできません。Context7 にリストされているプロジェクトは、Context7 ではなく、それぞれの所有者によって開発および保守されています。疑わしい、不適切な、または潜在的に有害なコンテンツを発見した場合は、プロジェクトページの「報告」ボタンを使用して、すぐにお知らせください。私たちはすべての報告を真剣に受け止め、プラットフォームの整合性と安全性を維持するために、フラグが付けられたコンテンツを迅速にレビューします。Context7 を使用することにより、あなたは自己の裁量とリスクで使用することを認めます。
|
||||
|
||||
## 🤝 私たちとつながる
|
||||
|
||||
最新情報を入手し、コミュニティに参加しましょう:
|
||||
|
||||
- 📢 最新ニュースとアップデートのために [X](https://x.com/contextai) でフォローしてください
|
||||
- 🌐 [Web サイト](https://context7.com) を訪問してください
|
||||
- 💬 [Discord コミュニティ](https://upstash.com/discord) に参加してください
|
||||
|
||||
## 📺 メディアでの Context7
|
||||
|
||||
- [Better Stack: "Free Tool Makes Cursor 10x Smarter"](https://youtu.be/52FC3qObp9E)
|
||||
- [Cole Medin: "This is Hands Down the BEST MCP Server for AI Coding Assistants"](https://www.youtube.com/watch?v=G7gK8H6u7Rs)
|
||||
- [Income Stream Surfers: "Context7 + SequentialThinking MCPs: Is This AGI?"](https://www.youtube.com/watch?v=-ggvzyLpK6o)
|
||||
- [Julian Goldie SEO: "Context7: New MCP AI Agent Update"](https://www.youtube.com/watch?v=CTZm6fBYisc)
|
||||
- [JeredBlu: "Context 7 MCP: Get Documentation Instantly + VS Code Setup"](https://www.youtube.com/watch?v=-ls0D-rtET4)
|
||||
- [Income Stream Surfers: "Context7: The New MCP Server That Will CHANGE AI Coding"](https://www.youtube.com/watch?v=PS-2Azb-C3M)
|
||||
- [AICodeKing: "Context7 + Cline & RooCode: This MCP Server Makes CLINE 100X MORE EFFECTIVE!"](https://www.youtube.com/watch?v=qZfENAPMnyo)
|
||||
- [Sean Kochel: "5 MCP Servers For Vibe Coding Glory (Just Plug-In & Go)"](https://www.youtube.com/watch?v=LqTQi8qexJM)
|
||||
|
||||
## ⭐ スター履歴
|
||||
|
||||
[](https://www.star-history.com/#upstash/context7&Date)
|
||||
|
||||
## 📄 ライセンス
|
||||
|
||||
MIT
|
@ -151,6 +151,7 @@ Claude Desktop의 `claude_desktop_config.json` 파일에 다음을 추가하세
|
||||
### 사용 가능한 도구
|
||||
|
||||
- `resolve-library-id`: 일반적인 라이브러리 이름을 Context7이 인식할 수 있는 라이브러리 ID로 변환합니다.
|
||||
|
||||
- `libraryName` (필수): 검색하고자 하는 라이브러리 이름
|
||||
|
||||
- `get-library-docs`: Context7이 인식하는 라이브러리 ID를 사용하여 해당 라이브러리의 문서를 가져옵니다.
|
||||
|
@ -58,7 +58,7 @@ npx -y @smithery/cli install @upstash/context7-mcp --client claude
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,7 +72,7 @@ npx -y @smithery/cli install @upstash/context7-mcp --client claude
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,7 +88,7 @@ npx -y @smithery/cli install @upstash/context7-mcp --client claude
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "deno",
|
||||
"args": ["run", "--allow-net", "npm:@upstash/context7-mcp"]
|
||||
"args": ["run", "--allow-env", "--allow-net", "npm:@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,7 @@ npx -y @smithery/cli install @upstash/context7-mcp --client claude
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,7 +124,7 @@ npx -y @smithery/cli install @upstash/context7-mcp --client claude
|
||||
"Context7": {
|
||||
"type": "stdio",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -140,7 +140,7 @@ npx -y @smithery/cli install @upstash/context7-mcp --client claude
|
||||
"Context7": {
|
||||
"command": {
|
||||
"path": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
},
|
||||
"settings": {}
|
||||
}
|
||||
@ -153,7 +153,7 @@ npx -y @smithery/cli install @upstash/context7-mcp --client claude
|
||||
Запустите следующую команду для установки. Смотрите [документацию Claude Code MCP](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#set-up-model-context-protocol-mcp) для получения дополнительной информации.
|
||||
|
||||
```sh
|
||||
claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
|
||||
claude mcp add context7 -- npx -y @upstash/context7-mcp
|
||||
```
|
||||
|
||||
### Установка в Claude Desktop
|
||||
@ -165,7 +165,22 @@ claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
|
||||
"mcpServers": {
|
||||
"Context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Установка в BoltAI
|
||||
|
||||
Откройте страницу "Settings", перейдите в "Plugins" и добавьте следующие JSON-строки:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"args": ["-y", "@upstash/context7-mcp"],
|
||||
"command": "npx"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,69 +190,88 @@ claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
|
||||
|
||||
Если вы предпочитаете запускать MCP сервер в Docker контейнере:
|
||||
|
||||
1. **Создайте образ Docker:**
|
||||
1. **Создайте образ Docker:**
|
||||
|
||||
Во-первых, создайте `Dockerfile` в корне вашего проекта (или в любом другом месте):
|
||||
Во-первых, создайте `Dockerfile` в корне вашего проекта (или в любом другом месте):
|
||||
|
||||
<details>
|
||||
<summary>Нажмите, чтобы просмотреть содержимое файла Dockerfile</summary>
|
||||
<details>
|
||||
<summary>Нажмите, чтобы просмотреть содержимое файла Dockerfile</summary>
|
||||
|
||||
```Dockerfile
|
||||
FROM node:18-alpine
|
||||
```Dockerfile
|
||||
FROM node:18-alpine
|
||||
|
||||
WORKDIR /app
|
||||
WORKDIR /app
|
||||
|
||||
# Установите последнюю версию пакета глобально
|
||||
RUN npm install -g @upstash/context7-mcp@latest
|
||||
# Установите последнюю версию пакета глобально
|
||||
RUN npm install -g @upstash/context7-mcp
|
||||
|
||||
# Откройте стандартный порт, если это необходимо (необязательно, это зависит от взаимодействия с MCP клиентом)
|
||||
# EXPOSE 3000
|
||||
# Откройте стандартный порт, если это необходимо (необязательно, это зависит от взаимодействия с MCP клиентом)
|
||||
# EXPOSE 3000
|
||||
|
||||
# Стандартная команда для запуска сервера
|
||||
CMD ["context7-mcp"]
|
||||
```
|
||||
# Стандартная команда для запуска сервера
|
||||
CMD ["context7-mcp"]
|
||||
```
|
||||
|
||||
</details>
|
||||
</details>
|
||||
|
||||
Затем, соберите образ, используя тег (например, `context7-mcp`). **Убедитесь, что Docker Desktop (или демон Docker) работает.** Запустите следующую команду в этой же директории, где сохранён `Dockerfile`:
|
||||
Затем, соберите образ, используя тег (например, `context7-mcp`). **Убедитесь, что Docker Desktop (или демон Docker) работает.** Запустите следующую команду в этой же директории, где сохранён `Dockerfile`:
|
||||
|
||||
```bash
|
||||
docker build -t context7-mcp .
|
||||
```
|
||||
```bash
|
||||
docker build -t context7-mcp .
|
||||
```
|
||||
|
||||
2. **Настройте ваш MCP клиент:**
|
||||
2. **Настройте ваш MCP клиент:**
|
||||
|
||||
Обновите вашу конфигурацию MCP клиента, чтобы использовать Docker команду.
|
||||
Обновите вашу конфигурацию MCP клиента, чтобы использовать Docker команду.
|
||||
|
||||
*Пример для cline_mcp_settings.json:*
|
||||
_Пример для cline_mcp_settings.json:_
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
}
|
||||
}
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
_Примечение: это пример конфигурации. Обратитесь к конкретным примерам для вашего MCP-клиента (например, Cursor, VS Code и т.д.), в предыдущих разделах этого README, чтобы адаптировать структуру (например, `mcpServers` вместо `servers`). Также убедитесь, что имя образа в `args` соответствует тегу, использованному при выполнении команды `docker build`._
|
||||
|
||||
### Установка в Windows
|
||||
|
||||
Конфигурация в Windows немного отличается от Linux или macOS (_в качестве примера используется `Cline`_). Однако, эти же же принципы применимы и к другим редакторам. В случае необходимости обратитесь к настройкам `command` и `args`.
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"github.com/upstash/context7-mcp": {
|
||||
"command": "cmd",
|
||||
"args": ["/c", "npx", "-y", "@upstash/context7-mcp"],
|
||||
"disabled": false,
|
||||
"autoApprove": []
|
||||
}
|
||||
```
|
||||
*Примечение: это пример конфигурации. Обратитесь к конкретным примерам для вашего MCP-клиента (например, Cursor, VS Code и т.д.), в предыдущих разделах этого README, чтобы адаптировать структуру (например, `mcpServers` вместо `servers`). Также убедитесь, что имя образа в `args` соответствует тегу, использованному при выполнении команды `docker build`.*
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Переменные окружения
|
||||
|
||||
- `DEFAULT_MINIMUM_TOKENS`: минимальное количество токенов, необходимое для получения документации (по умолчанию: 5000).
|
||||
- `DEFAULT_MINIMUM_TOKENS`: минимальное количество токенов, необходимое для получения документации (по умолчанию: 10000).
|
||||
|
||||
Examples:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"],
|
||||
"args": ["-y", "@upstash/context7-mcp"],
|
||||
"env": {
|
||||
"DEFAULT_MINIMUM_TOKENS": "10000"
|
||||
}
|
||||
@ -253,7 +287,7 @@ Examples:
|
||||
- `get-library-docs`: получает документацию по библиотеке по совместимому с Context7 идентификатору.
|
||||
- `context7CompatibleLibraryID` (обязательно)
|
||||
- `topic` (необязательно): фокусирует документацию на определённой теме (например, "routing", "hooks")
|
||||
- `tokens` (необязательно, по умолчанию 5000): максимальное число токенов в ответе. Значения ниже заданного `DEFAULT_MINIMUM_TOKENS` будут автоматически увеличены до него.
|
||||
- `tokens` (необязательно, по умолчанию 10000): максимальное число токенов в ответе. Значения ниже заданного `DEFAULT_MINIMUM_TOKENS` будут автоматически увеличены до него.
|
||||
|
||||
## Разработка
|
||||
|
||||
@ -285,7 +319,7 @@ bun run build
|
||||
### Тестирование с помощью инспектора MCP
|
||||
|
||||
```bash
|
||||
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
|
||||
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp
|
||||
```
|
||||
|
||||
## Решение проблем
|
||||
@ -299,7 +333,7 @@ npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -316,11 +350,22 @@ npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"--node-options=--experimental-vm-modules",
|
||||
"@upstash/context7-mcp@1.0.6"
|
||||
]
|
||||
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Проблемы с TLS/сертификатами
|
||||
|
||||
Используйте флаг `--experimental-fetch` c `npx`, чтобы избежать ошибки, связанные с TLS:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "--node-options=--experimental-fetch", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -328,7 +373,7 @@ npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
|
||||
|
||||
### Ошибки MCP клиента
|
||||
|
||||
1. Попробуйте убрать тег `@latest` из имени пакета.
|
||||
1. Попробуйте добавить тег `@latest` в имя пакета.
|
||||
|
||||
2. Попробуйте использовать `bunx` как альтернативу `npx`.
|
||||
|
||||
@ -337,13 +382,22 @@ npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
|
||||
4. Убедитесь, что используете версию Node v18 или выше, чтобы `npx` поддерживал встроенный `fetch`.
|
||||
|
||||
## Отказ от ответственности
|
||||
|
||||
Проекты Context7 создаются сообществом. Мы стремимся поддерживать высокое качество, однако не можем гарантировать точность, полноту или безопасность всей документации по библиотекам. Проекты, представленные в Context7, разрабатываются и поддерживаются их авторами, а не командой Context7.
|
||||
|
||||
Если вы столкнётесь с подозрительным, неуместным или потенциально вредоносным контентом, пожалуйста, воспользуйтесь кнопкой "Report" на странице проекта, чтобы немедленно сообщить нам. Мы внимательно относимся ко всем обращениям и оперативно проверяем помеченные материалы, чтобы обеспечить надёжность и безопасность платформы.
|
||||
|
||||
Используя Context7, вы признаёте, что делаете это по собственному усмотрению и на свой страх и риск.
|
||||
|
||||
## Context7 In Media
|
||||
## Оставайтесь с нами на связи
|
||||
|
||||
Будьте в курсе последних новостей на наших платформах:
|
||||
|
||||
- 📢 Следите за нашими новостями на [X](https://x.com/contextai), чтобы быть в курсе последних новостей
|
||||
- 🌐 Загляните на наш [сайт](https://context7.com)
|
||||
- 💬 При желании присоединяйтесь к нашему [сообществу в Discord](https://upstash.com/discord)
|
||||
|
||||
## Context7 в СМИ
|
||||
|
||||
- [Better Stack: "Бесплатный инструмент делает Cursor в 10 раз умнее"](https://youtu.be/52FC3qObp9E)
|
||||
- [Cole Medin: "Это, без сомнения, ЛУЧШИЙ MCP-сервер для AI-помощников в коде"](https://www.youtube.com/watch?v=G7gK8H6u7Rs)
|
||||
@ -351,6 +405,8 @@ npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
|
||||
- [Julian Goldie SEO: "Context7: обновление MCP-агента"](https://www.youtube.com/watch?v=CTZm6fBYisc)
|
||||
- [JeredBlu: "Context 7 MCP: мгновенный доступ к документации + настройка для VS Code"](https://www.youtube.com/watch?v=-ls0D-rtET4)
|
||||
- [Income stream surfers: "Context7: новый MCP-сервер, который изменит кодинг с ИИ"](https://www.youtube.com/watch?v=PS-2Azb-C3M)
|
||||
- [AICodeKing: "Context7 + Cline & RooCode: Этот MCP сервер делает CLINE в 100 раз ЭФФЕКТИВНЕЕ!"](https://www.youtube.com/watch?v=qZfENAPMnyo)
|
||||
- [Sean Kochel: "5 MCP серверов для стремительного вайб-программирования (Подключи и Работай)"](https://www.youtube.com/watch?v=LqTQi8qexJM)
|
||||
|
||||
## История звёзд на GitHub
|
||||
|
||||
|
360
docs/README.tr.md
Normal file
360
docs/README.tr.md
Normal file
@ -0,0 +1,360 @@
|
||||
# Context7 MCP - Herhangi Bir Prompt İçin Güncel Kod Belgeleri
|
||||
|
||||
[](https://context7.com) [](https://smithery.ai/server/@upstash/context7-mcp) [<img alt="VS Code'da Yükle (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Context7%20MCP%20Y%C3%BCkle&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
[](./docs/README.zh-CN.md) [](./docs/README.ko.md) [](./docs/README.es.md) [](./docs/README.fr.md) [-purple>)](./docs/README.pt-BR.md) [](./docs/README.it.md) [](./docs/README.id-ID.md) [](./docs/README.de.md) [](./docs/README.ru.md) [](./docs/README.tr.md)
|
||||
|
||||
## ❌ Context7 Olmadan
|
||||
|
||||
LLM'ler, kullandığınız kütüphaneler hakkında güncel olmayan veya genel bilgilere güvenir. Karşılaştığınız sorunlar:
|
||||
|
||||
- ❌ Kod örnekleri eskidir ve bir yıllık eğitim verilerine dayanır
|
||||
- ❌ Halüsinasyon yapılan API'ler gerçekte mevcut değildir
|
||||
- ❌ Eski paket sürümleri için genel cevaplar alırsınız
|
||||
|
||||
## ✅ Context7 İle
|
||||
|
||||
Context7 MCP, güncel ve sürüme özel belgeleri ve kod örneklerini doğrudan kaynağından çeker ve doğrudan prompt'unuza yerleştirir.
|
||||
|
||||
Cursor'da prompt'unuza `use context7` ekleyin:
|
||||
|
||||
```txt
|
||||
Next.js ile app router kullanan basit bir proje oluştur. use context7
|
||||
```
|
||||
|
||||
```txt
|
||||
PostgreSQL kimlik bilgileriyle şehir değeri "" olan satırları silmek için bir betik oluştur. use context7
|
||||
```
|
||||
|
||||
Context7, güncel kod örneklerini ve belgelerini doğrudan LLM'inizin içeriğine getirir.
|
||||
|
||||
- 1️⃣ Prompt'unuzu doğal bir şekilde yazın
|
||||
- 2️⃣ LLM'e `use context7` kullanmasını söyleyin
|
||||
- 3️⃣ Çalışan kod cevapları alın
|
||||
|
||||
Sekme değiştirme, var olmayan halüsinasyon API'ler, güncel olmayan kod üretimleri yok.
|
||||
|
||||
## 🛠️ Başlangıç
|
||||
|
||||
### Gereksinimler
|
||||
|
||||
- Node.js >= v18.0.0
|
||||
- Cursor, Windsurf, Claude Desktop veya başka bir MCP İstemcisi
|
||||
|
||||
### Smithery aracılığıyla kurulum
|
||||
|
||||
Context7 MCP Server'ı Claude Desktop için [Smithery](https://smithery.ai/server/@upstash/context7-mcp) aracılığıyla otomatik olarak kurmak için:
|
||||
|
||||
```bash
|
||||
npx -y @smithery/cli install @upstash/context7-mcp --client claude
|
||||
```
|
||||
|
||||
### Cursor'da Kurulum
|
||||
|
||||
Şu yolu izleyin: `Settings` -> `Cursor Settings` -> `MCP` -> `Add new global MCP server`
|
||||
|
||||
Aşağıdaki yapılandırmayı Cursor `~/.cursor/mcp.json` dosyanıza yapıştırmanız önerilen yaklaşımdır. Ayrıca, proje klasörünüzde `.cursor/mcp.json` oluşturarak belirli bir projeye de kurabilirsiniz. Daha fazla bilgi için [Cursor MCP belgelerine](https://docs.cursor.com/context/model-context-protocol) bakabilirsiniz.
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Alternatif: Bun Kullanın</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Alternatif: Deno Kullanın</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "deno",
|
||||
"args": ["run", "--allow-net", "npm:@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Windsurf'te Kurulum
|
||||
|
||||
Bunu Windsurf MCP yapılandırma dosyanıza ekleyin. Daha fazla bilgi için [Windsurf MCP belgelerine](https://docs.windsurf.com/windsurf/mcp) bakabilirsiniz.
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### VS Code'da Kurulum
|
||||
|
||||
[<img alt="VS Code'da Yükle (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Context7%20MCP%20Y%C3%BCkle&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
[<img alt="VS Code Insiders'da Yükle (npx)" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Context7%20MCP%20Y%C3%BCkle&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
Bunu VS Code MCP yapılandırma dosyanıza ekleyin. Daha fazla bilgi için [VS Code MCP belgelerine](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) bakabilirsiniz.
|
||||
|
||||
```json
|
||||
{
|
||||
"servers": {
|
||||
"Context7": {
|
||||
"type": "stdio",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Zed'de Kurulum
|
||||
|
||||
[Zed Uzantıları](https://zed.dev/extensions?query=Context7) aracılığıyla kurulabilir veya Zed `settings.json` dosyanıza ekleyebilirsiniz. Daha fazla bilgi için [Zed Context Server belgelerine](https://zed.dev/docs/assistant/context-servers) bakabilirsiniz.
|
||||
|
||||
```json
|
||||
{
|
||||
"context_servers": {
|
||||
"Context7": {
|
||||
"command": {
|
||||
"path": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
},
|
||||
"settings": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Claude Code'da Kurulum
|
||||
|
||||
Bu komutu çalıştırın. Daha fazla bilgi için [Claude Code MCP belgelerine](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#set-up-model-context-protocol-mcp) bakabilirsiniz.
|
||||
|
||||
```sh
|
||||
claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
|
||||
```
|
||||
|
||||
### Claude Desktop'ta Kurulum
|
||||
|
||||
Bunu Claude Desktop `claude_desktop_config.json` dosyanıza ekleyin. Daha fazla bilgi için [Claude Desktop MCP belgelerine](https://modelcontextprotocol.io/quickstart/user) bakabilirsiniz.
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Docker Kullanımı
|
||||
|
||||
MCP sunucusunu bir Docker konteynerinde çalıştırmayı tercih ederseniz:
|
||||
|
||||
1. **Docker Görüntüsü Oluşturun:**
|
||||
|
||||
Önce, proje kökünde (veya tercih ettiğiniz herhangi bir yerde) bir `Dockerfile` oluşturun:
|
||||
|
||||
<details>
|
||||
<summary>Dockerfile içeriğini görmek için tıklayın</summary>
|
||||
|
||||
```Dockerfile
|
||||
FROM node:18-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# En son sürümü global olarak yükleyin
|
||||
RUN npm install -g @upstash/context7-mcp@latest
|
||||
|
||||
# Gerekirse varsayılan portu açın (isteğe bağlı, MCP istemci etkileşimine bağlıdır)
|
||||
# EXPOSE 3000
|
||||
|
||||
# Sunucuyu çalıştırmak için varsayılan komut
|
||||
CMD ["context7-mcp"]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
Ardından, bir etiket (örneğin, `context7-mcp`) kullanarak görüntüyü oluşturun. **Docker Desktop'un (veya Docker daemon'un) çalıştığından emin olun.** `Dockerfile`'ı kaydettiğiniz dizinde aşağıdaki komutu çalıştırın:
|
||||
|
||||
```bash
|
||||
docker build -t context7-mcp .
|
||||
```
|
||||
|
||||
2. **MCP İstemcinizi Yapılandırın:**
|
||||
|
||||
MCP istemcinizin yapılandırmasını Docker komutunu kullanacak şekilde güncelleyin.
|
||||
|
||||
_cline_mcp_settings.json için örnek:_
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
_Not: Bu bir örnek yapılandırmadır. Yapıyı uyarlamak için MCP istemcinize (Cursor, VS Code vb.) özel örneklere bakın (örneğin, `mcpServers` ve `servers` farkı). Ayrıca, `args` içindeki görüntü adının `docker build` komutu sırasında kullanılan etiketle eşleştiğinden emin olun._
|
||||
|
||||
### Çevre Değişkenleri
|
||||
|
||||
- `DEFAULT_MINIMUM_TOKENS`: Belge alımı için minimum token sayısını ayarlayın (varsayılan: 10000).
|
||||
|
||||
Örnekler:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"],
|
||||
"env": {
|
||||
"DEFAULT_MINIMUM_TOKENS": "10000"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Kullanılabilir Araçlar
|
||||
|
||||
- `resolve-library-id`: Genel bir kütüphane adını Context7 uyumlu bir kütüphane ID'sine dönüştürür.
|
||||
- `libraryName` (gerekli)
|
||||
- `get-library-docs`: Context7 uyumlu bir kütüphane ID'si kullanarak bir kütüphane için belgeleri getirir.
|
||||
- `context7CompatibleLibraryID` (gerekli)
|
||||
- `topic` (isteğe bağlı): Belgeleri belirli bir konuya odaklayın (örn. "routing", "hooks")
|
||||
- `tokens` (isteğe bağlı, varsayılan 10000): Döndürülecek maksimum token sayısı. Yapılandırılmış `DEFAULT_MINIMUM_TOKENS` değerinden veya varsayılan 10000 değerinden düşük değerler otomatik olarak o değere yükseltilir.
|
||||
|
||||
## Geliştirme
|
||||
|
||||
Projeyi klonlayın ve bağımlılıkları yükleyin:
|
||||
|
||||
```bash
|
||||
bun i
|
||||
```
|
||||
|
||||
Derleyin:
|
||||
|
||||
```bash
|
||||
bun run build
|
||||
```
|
||||
|
||||
### Yerel Yapılandırma Örneği
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["tsx", "/path/to/folder/context7-mcp/src/index.ts"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### MCP Inspector ile Test Etme
|
||||
|
||||
```bash
|
||||
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
|
||||
```
|
||||
|
||||
## Sorun Giderme
|
||||
|
||||
### ERR_MODULE_NOT_FOUND
|
||||
|
||||
Bu hatayı görürseniz, `npx` yerine `bunx` kullanmayı deneyin.
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Bu, özellikle `npx`'in paketleri düzgün şekilde yüklemediği veya çözemediği ortamlarda modül çözümleme sorunlarını genellikle çözer.
|
||||
|
||||
### ESM Çözümleme Sorunları
|
||||
|
||||
`Error: Cannot find module 'uriTemplate.js'` gibi bir hatayla karşılaşırsanız, `--experimental-vm-modules` bayrağıyla çalıştırmayı deneyin:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/context7-mcp@1.0.6"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### MCP İstemci Hataları
|
||||
|
||||
1. Paket adından `@latest` ifadesini kaldırmayı deneyin.
|
||||
|
||||
2. Alternatif olarak `bunx` kullanmayı deneyin.
|
||||
|
||||
3. Alternatif olarak `deno` kullanmayı deneyin.
|
||||
|
||||
4. `npx` ile yerel fetch desteğine sahip olmak için Node v18 veya daha yüksek bir sürüm kullandığınızdan emin olun.
|
||||
|
||||
## Sorumluluk Reddi
|
||||
|
||||
Context7 projeleri topluluk katkılıdır ve yüksek kaliteyi korumaya çalışsak da, tüm kütüphane belgelerinin doğruluğunu, eksiksizliğini veya güvenliğini garanti edemeyiz. Context7'de listelenen projeler, Context7 tarafından değil, ilgili sahipleri tarafından geliştirilmekte ve sürdürülmektedir. Şüpheli, uygunsuz veya potansiyel olarak zararlı içerikle karşılaşırsanız, lütfen bizi hemen bilgilendirmek için proje sayfasındaki "Bildir" düğmesini kullanın. Tüm bildirimleri ciddiye alıyoruz ve platformumuzun bütünlüğünü ve güvenliğini korumak için işaretlenen içeriği hızla inceleyeceğiz. Context7'yi kullanarak, bunu kendi takdirinizle ve riskinizle yaptığınızı kabul etmiş olursunuz.
|
||||
|
||||
## Context7 Medyada
|
||||
|
||||
- [Better Stack: "Ücretsiz Araç Cursor'u 10 Kat Daha Akıllı Yapıyor"](https://youtu.be/52FC3qObp9E)
|
||||
- [Cole Medin: "Bu, Tartışmasız AI Kodlama Asistanları İçin EN İYİ MCP Sunucusudur"](https://www.youtube.com/watch?v=G7gK8H6u7Rs)
|
||||
- [Income stream surfers: "Context7 + SequentialThinking MCP'leri: Bu AGI mi?"](https://www.youtube.com/watch?v=-ggvzyLpK6o)
|
||||
- [Julian Goldie SEO: "Context7: Yeni MCP AI Aracı Güncellemesi"](https://www.youtube.com/watch?v=CTZm6fBYisc)
|
||||
- [JeredBlu: "Context 7 MCP: Belgeleri Anında Alın + VS Code Kurulumu"](https://www.youtube.com/watch?v=-ls0D-rtET4)
|
||||
- [Income stream surfers: "Context7: AI Kodlamayı DEĞİŞTİRECEK Yeni MCP Sunucusu"](https://www.youtube.com/watch?v=PS-2Azb-C3M)
|
||||
- [AICodeKing: "Context7 + Cline & RooCode: Bu MCP Sunucusu CLINE'ı 100 KAT DAHA ETKİLİ YAPIYOR!"](https://www.youtube.com/watch?v=qZfENAPMnyo)
|
||||
- [Sean Kochel: "Vibe Kodlama İhtişamı İçin 5 MCP Sunucusu (Tak ve Çalıştır)"](https://www.youtube.com/watch?v=LqTQi8qexJM)
|
||||
|
||||
## Yıldız Geçmişi
|
||||
|
||||
[](https://www.star-history.com/#upstash/context7&Date)
|
||||
|
||||
## Lisans
|
||||
|
||||
MIT
|
@ -187,15 +187,15 @@ claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
|
||||
|
||||
更新MCP客户端配置以使用Docker命令。
|
||||
|
||||
*cline_mcp_settings.json配置示例:*
|
||||
_cline_mcp_settings.json配置示例:_
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
@ -203,11 +203,30 @@ claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
|
||||
}
|
||||
}
|
||||
```
|
||||
*注意事项:*
|
||||
|
||||
_注意事项:_
|
||||
<em>
|
||||
|
||||
- 此为示例配置。请参考前面README中针对具体MCP客户端(如Cursor、VS Code等)的示例来调整结构(如`mcpServers`与`servers`)。同时确保`args`中的镜像名称与`docker build`命令使用的标签一致。
|
||||
- 当前Cursor版本(0.49.5), 请不要使用本方式启动MCP server,详情:[Cursor官方说明](https://docs.cursor.com/context/model-context-protocol#remote-development)
|
||||
</em>
|
||||
</em>
|
||||
|
||||
### 在Windows上安装
|
||||
|
||||
在windows上的配置相对于linux或macos来说有些许不同,(_示例使用的`Cline`_), 其它编辑器同理, 参考`command`和`args`的配置即可
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"github.com/upstash/context7-mcp": {
|
||||
"command": "cmd",
|
||||
"args": ["/c", "npx", "-y", "@upstash/context7-mcp@latest"],
|
||||
"disabled": false,
|
||||
"autoApprove": []
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 可用工具
|
||||
|
||||
@ -251,7 +270,6 @@ bun run build
|
||||
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
|
||||
```
|
||||
|
||||
|
||||
## 故障排除
|
||||
|
||||
### ERR_MODULE_NOT_FOUND
|
||||
|
549
docs/README.zh-TW.md
Normal file
549
docs/README.zh-TW.md
Normal file
@ -0,0 +1,549 @@
|
||||
# Context7 MCP - 即時更新的程式碼文件,適用於任何提示
|
||||
|
||||
[](https://context7.com) [](https://smithery.ai/server/@upstash/context7-mcp) [<img alt="在 VS Code 中安裝 (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=安裝%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
## ❌ 沒有 Context7
|
||||
|
||||
大型語言模型(LLM)依賴過時或通用的函式庫資訊。你會遇到:
|
||||
|
||||
- ❌ 程式碼範例過時,僅根據一年前的訓練資料
|
||||
- ❌ 產生不存在的 API
|
||||
- ❌ 舊版套件的通用答案
|
||||
|
||||
## ✅ 有了 Context7
|
||||
|
||||
Context7 MCP 直接從來源拉取即時、特定版本的文件與程式碼範例,並直接放入你的提示中。
|
||||
|
||||
在 Cursor 的提示中加入 `use context7`:
|
||||
|
||||
```txt
|
||||
建立一個使用 app router 的基本 Next.js 專案。use context7
|
||||
```
|
||||
|
||||
```txt
|
||||
根據 PostgreSQL 資訊,建立一個刪除 city 為 "" 的資料列的腳本。use context7
|
||||
```
|
||||
|
||||
Context7 會將即時的程式碼範例與文件直接帶入你的 LLM 上下文。
|
||||
|
||||
- 1️⃣ 自然地撰寫你的提示
|
||||
- 2️⃣ 告訴 LLM `use context7`
|
||||
- 3️⃣ 取得可執行的程式碼解答
|
||||
|
||||
不需切換分頁、不會產生不存在的 API、不會有過時的程式碼。
|
||||
|
||||
## 📚 新增專案
|
||||
|
||||
請參考我們的[專案新增指南](./docs/adding-projects.md),學習如何將你喜愛的函式庫加入 Context7 或更新其內容。
|
||||
|
||||
## 🛠️ 安裝
|
||||
|
||||
### 系統需求
|
||||
|
||||
- Node.js >= v18.0.0
|
||||
- Cursor、Windsurf、Claude Desktop 或其他 MCP 客戶端
|
||||
|
||||
<details>
|
||||
<summary><b>透過 Smithery 安裝</b></summary>
|
||||
|
||||
要透過 [Smithery](https://smithery.ai/server/@upstash/context7-mcp) 自動安裝 Context7 MCP Server:
|
||||
|
||||
```bash
|
||||
npx -y @smithery/cli@latest install @upstash/context7-mcp --client <CLIENT_NAME> --key <YOUR_SMITHERY_KEY>
|
||||
```
|
||||
|
||||
你的 Smithery 金鑰可在 [Smithery.ai 網頁](https://smithery.ai/server/@upstash/context7-mcp) 取得。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>在 Cursor 安裝</b></summary>
|
||||
|
||||
前往:`Settings` -> `Cursor Settings` -> `MCP` -> `Add new global MCP server`
|
||||
|
||||
建議將下列設定貼到你的 Cursor `~/.cursor/mcp.json` 檔案。你也可以在專案資料夾建立 `.cursor/mcp.json` 進行專案安裝。詳見 [Cursor MCP 文件](https://docs.cursor.com/context/model-context-protocol)。
|
||||
|
||||
#### Cursor 遠端伺服器連線
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Cursor 本地伺服器連線
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>替代方案:使用 Bun</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>替代方案:使用 Deno</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "deno",
|
||||
"args": ["run", "--allow-env", "--allow-net", "npm:@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>在 Windsurf 安裝</b></summary>
|
||||
|
||||
將下列內容加入 Windsurf MCP 設定檔。詳見 [Windsurf MCP 文件](https://docs.windsurf.com/windsurf/mcp)。
|
||||
|
||||
#### Windsurf 遠端伺服器連線
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"serverUrl": "https://mcp.context7.com/sse"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Windsurf 本地伺服器連線
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>在 VS Code 安裝</b></summary>
|
||||
|
||||
[<img alt="在 VS Code 中安裝 (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=安裝Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
[<img alt="在 VS Code Insiders 中安裝 (npx)" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=安裝Context7%20MCP&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
|
||||
|
||||
將下列內容加入 VS Code MCP 設定檔。詳見 [VS Code MCP 文件](https://code.visualstudio.com/docs/copilot/chat/mcp-servers)。
|
||||
|
||||
#### VS Code 遠端伺服器連線
|
||||
|
||||
```json
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"context7": {
|
||||
"type": "http",
|
||||
"url": "https://mcp.context7.com/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### VS Code 本地伺服器連線
|
||||
|
||||
```json
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"context7": {
|
||||
"type": "stdio",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>在 Zed 安裝</b></summary>
|
||||
|
||||
可透過 [Zed 擴充套件](https://zed.dev/extensions?query=Context7) 安裝,或將下列內容加入 Zed `settings.json`。詳見 [Zed Context Server 文件](https://zed.dev/docs/assistant/context-servers)。
|
||||
|
||||
```json
|
||||
{
|
||||
"context_servers": {
|
||||
"Context7": {
|
||||
"command": {
|
||||
"path": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
},
|
||||
"settings": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>在 Claude Code 安裝</b></summary>
|
||||
|
||||
執行下列指令。詳見 [Claude Code MCP 文件](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#set-up-model-context-protocol-mcp)。
|
||||
|
||||
#### Claude Code 遠端伺服器連線
|
||||
|
||||
```sh
|
||||
claude mcp add --transport sse context7 https://mcp.context7.com/sse
|
||||
```
|
||||
|
||||
#### Claude Code 本地伺服器連線
|
||||
|
||||
```sh
|
||||
claude mcp add context7 -- npx -y @upstash/context7-mcp
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>在 Claude Desktop 安裝</b></summary>
|
||||
|
||||
將下列內容加入 Claude Desktop `claude_desktop_config.json`。詳見 [Claude Desktop MCP 文件](https://modelcontextprotocol.io/quickstart/user)。
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>在 BoltAI 安裝</b></summary>
|
||||
|
||||
打開應用程式的「Settings」頁面,前往「Plugins」,並輸入下列 JSON:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
儲存後,在聊天中輸入 `get-library-docs` 並接上你的 Context7 文件 ID(例如 `get-library-docs /nuxt/ui`)。更多資訊請參考 [BoltAI 文件網站](https://docs.boltai.com/docs/plugins/mcp-servers)。如在 iOS 上使用 BoltAI,請參考[此指南](https://docs.boltai.com/docs/boltai-mobile/mcp-servers)。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>使用 Docker</b></summary>
|
||||
|
||||
若你偏好在 Docker 容器中執行 MCP 伺服器:
|
||||
|
||||
1. **建立 Docker 映像檔:**
|
||||
|
||||
先在專案根目錄(或任意位置)建立 `Dockerfile`:
|
||||
|
||||
<details>
|
||||
<summary>點擊查看 Dockerfile 內容</summary>
|
||||
|
||||
```Dockerfile
|
||||
FROM node:18-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 全域安裝最新版
|
||||
RUN npm install -g @upstash/context7-mcp
|
||||
|
||||
# 如有需要可開放預設埠(視 MCP 客戶端互動而定)
|
||||
# EXPOSE 3000
|
||||
|
||||
# 預設啟動指令
|
||||
CMD ["context7-mcp"]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
然後使用標籤(如 `context7-mcp`)建構映像檔。**請確保 Docker Desktop(或 Docker daemon)已啟動。**在存有 `Dockerfile` 的目錄執行:
|
||||
|
||||
```bash
|
||||
docker build -t context7-mcp .
|
||||
```
|
||||
|
||||
2. **設定 MCP 客戶端:**
|
||||
|
||||
更新 MCP 客戶端設定以使用 Docker 指令。
|
||||
|
||||
_cline_mcp_settings.json 範例:_
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"Сontext7": {
|
||||
"autoApprove": [],
|
||||
"disabled": false,
|
||||
"timeout": 60,
|
||||
"command": "docker",
|
||||
"args": ["run", "-i", "--rm", "context7-mcp"],
|
||||
"transportType": "stdio"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
_注意:這是範例設定。請參考前述各 MCP 客戶端(如 Cursor、VS Code 等)的範例調整結構(如 `mcpServers` 與 `servers`)。同時確保 `args` 中的映像名稱與 `docker build` 使用的標籤一致。_
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>在 Windows 安裝</b></summary>
|
||||
|
||||
Windows 的設定與 Linux 或 macOS 略有不同(*範例以 Cline 為例*)。其他編輯器同理,請參考 `command` 與 `args` 設定。
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"github.com/upstash/context7-mcp": {
|
||||
"command": "cmd",
|
||||
"args": ["/c", "npx", "-y", "@upstash/context7-mcp@latest"],
|
||||
"disabled": false,
|
||||
"autoApprove": []
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>在 Augment Code 安裝</b></summary>
|
||||
|
||||
在 Augment Code 設定 Context7 MCP,請依下列步驟:
|
||||
|
||||
1. 按 Cmd/Ctrl Shift P 或於 Augment 面板的漢堡選單中選擇
|
||||
2. 選擇 Edit Settings
|
||||
3. 於 Advanced 下點選 Edit in settings.json
|
||||
4. 將伺服器設定加入 `augment.advanced` 物件的 `mcpServers` 陣列
|
||||
|
||||
```json
|
||||
"augment.advanced": {
|
||||
"mcpServers": [
|
||||
{
|
||||
"name": "context7",
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
加入 MCP 伺服器後,請重啟編輯器。如遇錯誤,請檢查語法是否有遺漏括號或逗號。
|
||||
|
||||
</details>
|
||||
|
||||
## 🔧 環境變數
|
||||
|
||||
Context7 MCP 伺服器支援下列環境變數:
|
||||
|
||||
- `DEFAULT_MINIMUM_TOKENS`:設定文件擷取的最小 token 數(預設:10000)
|
||||
|
||||
範例設定:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp"],
|
||||
"env": {
|
||||
"DEFAULT_MINIMUM_TOKENS": "6000"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 🔨 可用工具
|
||||
|
||||
Context7 MCP 提供下列工具供 LLM 使用:
|
||||
|
||||
- `resolve-library-id`:將一般函式庫名稱解析為 Context7 相容的函式庫 ID。
|
||||
|
||||
- `libraryName`(必填):要查詢的函式庫名稱
|
||||
|
||||
- `get-library-docs`:根據 Context7 相容的函式庫 ID 取得文件。
|
||||
- `context7CompatibleLibraryID`(必填):Context7 相容的函式庫 ID(如 `/mongodb/docs`, `/vercel/next.js`)
|
||||
- `topic`(選填):聚焦於特定主題(如 "routing", "hooks")
|
||||
- `tokens`(選填,預設 10000):最大回傳 token 數。小於預設或 `DEFAULT_MINIMUM_TOKENS` 的值會自動提升。
|
||||
|
||||
## 💻 開發
|
||||
|
||||
複製專案並安裝依賴:
|
||||
|
||||
```bash
|
||||
bun i
|
||||
```
|
||||
|
||||
建置:
|
||||
|
||||
```bash
|
||||
bun run build
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary><b>本地設定範例</b></summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["tsx", "/path/to/folder/context7-mcp/src/index.ts"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>使用 MCP Inspector 測試</b></summary>
|
||||
|
||||
```bash
|
||||
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## 🚨 疑難排解
|
||||
|
||||
<details>
|
||||
<summary><b>找不到模組錯誤</b></summary>
|
||||
|
||||
若遇到 `ERR_MODULE_NOT_FOUND`,請嘗試用 `bunx` 取代 `npx`:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "bunx",
|
||||
"args": ["-y", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
這通常能解決 `npx` 無法正確安裝或解析套件的問題。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>ESM 解析問題</b></summary>
|
||||
|
||||
若出現 `Error: Cannot find module 'uriTemplate.js'`,請嘗試加上 `--experimental-vm-modules` 參數:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/context7-mcp@1.0.6"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>TLS/憑證問題</b></summary>
|
||||
|
||||
可加上 `--experimental-fetch` 參數繞過 TLS 問題:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "--node-options=--experimental-fetch", "@upstash/context7-mcp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>一般 MCP 客戶端錯誤</b></summary>
|
||||
|
||||
1. 嘗試加上 `@latest` 於套件名稱
|
||||
2. 改用 `bunx` 取代 `npx`
|
||||
3. 或改用 `deno`
|
||||
4. 請確認 Node.js 版本為 v18 或以上,以支援原生 fetch
|
||||
|
||||
</details>
|
||||
|
||||
## ⚠️ 免責聲明
|
||||
|
||||
Context7 專案由社群貢獻,雖然我們致力於維持高品質,但無法保證所有函式庫文件的正確性、完整性或安全性。Context7 上的專案由各自擁有者開發與維護,非 Context7 官方。若發現可疑、不當或潛在有害內容,請於專案頁面點選「檢舉」按鈕通知我們。我們會嚴肅處理所有檢舉,並盡快審查標記內容,以維護平台的完整性與安全。使用 Context7 即表示你同意自行承擔風險。
|
||||
|
||||
## 🤝 與我們聯繫
|
||||
|
||||
歡迎追蹤與加入社群:
|
||||
|
||||
- 📢 追蹤我們的 [X](https://x.com/contextai) 以獲取最新消息
|
||||
- 🌐 造訪我們的 [官方網站](https://context7.com)
|
||||
- 💬 加入我們的 [Discord 社群](https://upstash.com/discord)
|
||||
|
||||
## 📺 Context7 媒體報導
|
||||
|
||||
- [Better Stack:「免費工具讓 Cursor 智慧提升 10 倍」](https://youtu.be/52FC3qObp9E)
|
||||
- [Cole Medin:「這絕對是 AI 程式助理最強 MCP 伺服器」](https://www.youtube.com/watch?v=G7gK8H6u7Rs)
|
||||
- [Income Stream Surfers:「Context7 + SequentialThinking MCPs:這是 AGI 嗎?」](https://www.youtube.com/watch?v=-ggvzyLpK6o)
|
||||
- [Julian Goldie SEO:「Context7:全新 MCP AI 代理更新」](https://www.youtube.com/watch?v=CTZm6fBYisc)
|
||||
- [JeredBlu:「Context 7 MCP:即時獲取文件 + VS Code 設定」](https://www.youtube.com/watch?v=-ls0D-rtET4)
|
||||
- [Income Stream Surfers:「Context7:將改變 AI 程式開發的新 MCP 伺服器」](https://www.youtube.com/watch?v=PS-2Azb-C3M)
|
||||
- [AICodeKing:「Context7 + Cline & RooCode:這個 MCP 伺服器讓 CLINE 效率提升 100 倍!」](https://www.youtube.com/watch?v=qZfENAPMnyo)
|
||||
- [Sean Kochel:「5 個 MCP 伺服器讓你程式開發如虎添翼(即插即用)」](https://www.youtube.com/watch?v=LqTQi8qexJM)
|
||||
|
||||
## ⭐ 星標歷史
|
||||
|
||||
[](https://www.star-history.com/#upstash/context7&Date)
|
||||
|
||||
## 📄 授權
|
||||
|
||||
MIT
|
118
docs/adding-projects.md
Normal file
118
docs/adding-projects.md
Normal file
@ -0,0 +1,118 @@
|
||||
# Adding Projects to Context7
|
||||
|
||||
Context7 allows you to add your favorite libraries and frameworks to help developers get up-to-date documentation directly in their coding environment.
|
||||
|
||||
## Quick Submission
|
||||
|
||||
The easiest way to add a library is through our web interface:
|
||||
|
||||
**[Submit a Library →](https://context7.com/add-library?tab=github)**
|
||||
|
||||
Simply provide the GitHub repository URL and Context7 will automatically parse and index the project's documentation.
|
||||
|
||||
## Advanced Configuration with `context7.json`
|
||||
|
||||
For more control over how Context7 parses and presents your library, you can add a `context7.json` file to the root of your repository. This file works similar to `robots.txt` and tells Context7 how to handle your project.
|
||||
|
||||
### Configuration Fields
|
||||
|
||||
Here's an example `context7.json` file with all available options:
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "https://context7.com/schema/context7.json",
|
||||
"projectTitle": "Upstash Ratelimit",
|
||||
"description": "Ratelimiting library based on Upstash Redis",
|
||||
"folders": [],
|
||||
"excludeFolders": ["src"],
|
||||
"excludeFiles": [],
|
||||
"rules": ["Use Upstash Redis as a database", "Use single region set up"],
|
||||
"previousVersions": [
|
||||
{
|
||||
"tag": "v1.2.1",
|
||||
"title": "version 1.2.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> **💡 Pro Tip**: Including the `$schema` field enables autocomplete, validation, and helpful tooltips in modern code editors like VS Code, making it easier to create and maintain your configuration.
|
||||
|
||||
#### Field Descriptions
|
||||
|
||||
- **`projectTitle`** (string): The display name for your project in Context7. This overrides the default repository name.
|
||||
|
||||
- **`description`** (string): A brief description of what your library does. This helps coding agents understand the purpose of your project.
|
||||
|
||||
- **`folders`** (array): Specific folder paths to include when parsing documentation. If empty, Context7 will scan the entire repository for relevant documentation files. Supports regex patterns and requires full paths.
|
||||
|
||||
- **`excludeFolders`** (array): Folder paths to exclude from documentation parsing. Useful for excluding source code directories, build folders, or other non-documentation content. Supports regex patterns and requires full paths.
|
||||
|
||||
- **`excludeFiles`** (array): Specific file names to exclude from documentation parsing. Only include the filename (not the path). Useful for excluding files like `CHANGELOG.md`, license files, or other non-documentation content that might not be relevant for coding agents. Regex patterns are not supported.
|
||||
|
||||
- **`rules`** (array): Best practices or important guidelines that coding agents should follow when using your library. These appear as recommendations in the documentation context provided to coding agents.
|
||||
|
||||
- **`previousVersions`** (array): Information about previous versions of your library that should also be available in Context7.
|
||||
- **`tag`**: The Git tag or version identifier
|
||||
- **`title`**: Human-readable version name
|
||||
|
||||
### Default Exclusions
|
||||
|
||||
If you don't specify `excludeFiles` or `excludeFolders` in your `context7.json`, Context7 uses these default patterns:
|
||||
|
||||
#### Default Excluded Files
|
||||
|
||||
```
|
||||
CHANGELOG.md, changelog.md, CHANGELOG.mdx, changelog.mdx
|
||||
LICENSE.md, license.md
|
||||
CODE_OF_CONDUCT.md, code_of_conduct.md
|
||||
```
|
||||
|
||||
#### Default Excluded Folders
|
||||
|
||||
```
|
||||
*archive*, *archived*, old, docs/old, *deprecated*, *legacy*
|
||||
*previous*, *outdated*, *superseded*
|
||||
i18n/zh*, i18n/es*, i18n/fr*, i18n/de*, i18n/ja*, i18n/ko*
|
||||
i18n/ru*, i18n/pt*, i18n/it*, i18n/ar*, i18n/hi*, i18n/tr*
|
||||
i18n/nl*, i18n/pl*, i18n/sv*, i18n/vi*, i18n/th*
|
||||
zh-cn, zh-tw, zh-hk, zh-mo, zh-sg
|
||||
```
|
||||
|
||||
These defaults help ensure that coding agents receive relevant, current documentation without outdated or non-technical content.
|
||||
|
||||
## Who Can Add Configuration?
|
||||
|
||||
- **Library authors**: Add `context7.json` directly to your repository
|
||||
- **Contributors**: Submit pull requests to add or update the configuration
|
||||
- **Community members**: Propose improvements to how popular libraries are parsed
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Keep descriptions concise**: Aim for one clear sentence that explains your library's purpose to coding agents
|
||||
2. **Exclude irrelevant folders**: Use `excludeFolders` to avoid indexing source code, tests, or build artifacts
|
||||
3. **Add helpful rules**: Include common gotchas or best practices that coding agents should know when generating code
|
||||
4. **Maintain version history**: Keep important previous versions accessible for projects that need older APIs
|
||||
|
||||
## Adding a Version
|
||||
|
||||
To add a new version to your existing library:
|
||||
|
||||
1. **Add version to the `context7.json` file**: Update the `previousVersions` array with your new version:
|
||||
|
||||
```json
|
||||
"previousVersions": [
|
||||
{
|
||||
"tag": "v2.0.0",
|
||||
"title": "version 2.0.0"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
> **Note**: The `tag` value must exactly match an existing Git tag in your GitHub repository.
|
||||
|
||||
2. **Refresh your library**: Go to your library page on Context7 and trigger a refresh to index the new version.
|
||||
|
||||
## Need Help?
|
||||
|
||||
If you encounter issues or need assistance adding your project, please [report an issue](https://context7.com/add-library?tab=github) or reach out to our community.
|
10
package.json
10
package.json
@ -1,12 +1,14 @@
|
||||
{
|
||||
"name": "@upstash/context7-mcp",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.0",
|
||||
"description": "MCP server for Context7",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "tsc && chmod 755 dist/index.js",
|
||||
"format": "prettier --write .",
|
||||
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix"
|
||||
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
|
||||
"lint:check": "eslint \"**/*.{js,ts,tsx}\"",
|
||||
"start": "node dist/index.js --transport http"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -31,8 +33,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/upstash/context7#readme",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.8.0",
|
||||
"dotenv": "^16.5.0",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"commander": "^14.0.0",
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
130
schema/context7.json
Normal file
130
schema/context7.json
Normal file
@ -0,0 +1,130 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://context7.com/schema/context7.json",
|
||||
"title": "Context7 Configuration Schema",
|
||||
"description": "Configuration file for Context7 project parsing and documentation generation",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"projectTitle": {
|
||||
"type": "string",
|
||||
"description": "The display name for your project in Context7. This overrides the default repository name.",
|
||||
"minLength": 1,
|
||||
"maxLength": 100,
|
||||
"examples": ["Upstash Ratelimit", "Next.js", "React Query"]
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"description": "A brief description of what your library does. This helps coding agents understand the purpose of your project.",
|
||||
"minLength": 10,
|
||||
"maxLength": 200,
|
||||
"examples": [
|
||||
"Ratelimiting library based on Upstash Redis",
|
||||
"The React Framework for Production",
|
||||
"Powerful data synchronization for React"
|
||||
]
|
||||
},
|
||||
"folders": {
|
||||
"type": "array",
|
||||
"description": "Specific folder paths to include when parsing documentation. If empty, Context7 will scan the entire repository. Supports regex patterns and requires full paths.",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"uniqueItems": true,
|
||||
"default": [],
|
||||
"examples": [
|
||||
["docs", "guides", "examples"],
|
||||
["documentation/**"],
|
||||
["api-reference", "tutorials/*"]
|
||||
]
|
||||
},
|
||||
"excludeFolders": {
|
||||
"type": "array",
|
||||
"description": "Folder paths to exclude from documentation parsing. Supports regex patterns and requires full paths.",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"uniqueItems": true,
|
||||
"default": [],
|
||||
"examples": [
|
||||
["src", "build", "node_modules"],
|
||||
["**/test/**", "**/tests/**"],
|
||||
["legacy/*", "archive"]
|
||||
]
|
||||
},
|
||||
"excludeFiles": {
|
||||
"type": "array",
|
||||
"description": "Specific file names to exclude from documentation parsing. Only include the filename (not the path). Regex patterns are not supported.",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"pattern": "^[^/\\\\]+$"
|
||||
},
|
||||
"uniqueItems": true,
|
||||
"default": [],
|
||||
"examples": [
|
||||
["CHANGELOG.md", "LICENSE"],
|
||||
["README-dev.md", "CONTRIBUTING.md"],
|
||||
["package.json", "tsconfig.json"]
|
||||
]
|
||||
},
|
||||
"rules": {
|
||||
"type": "array",
|
||||
"description": "Best practices or important guidelines that coding agents should follow when using your library. These appear as recommendations in the documentation context.",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 5,
|
||||
"maxLength": 200
|
||||
},
|
||||
"default": [],
|
||||
"examples": [
|
||||
["Always use TypeScript for better type safety"],
|
||||
["Use Upstash Redis as a database", "Use single region set up"],
|
||||
["Import components from the main package", "Follow the naming conventions"]
|
||||
]
|
||||
},
|
||||
"previousVersions": {
|
||||
"type": "array",
|
||||
"description": "Information about previous versions of your library that should also be available in Context7.",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tag": {
|
||||
"type": "string",
|
||||
"description": "The Git tag or version identifier",
|
||||
"pattern": "^v?\\d+\\.\\d+\\.\\d+",
|
||||
"examples": ["v1.2.1", "2.0.0", "v3.1.0-beta.1"]
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
"description": "Human-readable version name",
|
||||
"minLength": 1,
|
||||
"maxLength": 50,
|
||||
"examples": ["version 1.2.1", "Legacy Version", "Beta Release"]
|
||||
}
|
||||
},
|
||||
"required": ["tag", "title"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"default": []
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"examples": [
|
||||
{
|
||||
"projectTitle": "Upstash Ratelimit",
|
||||
"description": "Ratelimiting library based on Upstash Redis",
|
||||
"folders": [],
|
||||
"excludeFolders": ["src"],
|
||||
"excludeFiles": [],
|
||||
"rules": ["Use Upstash Redis as a database", "Use single region set up"],
|
||||
"previousVersions": [
|
||||
{
|
||||
"tag": "v1.2.1",
|
||||
"title": "version 1.2.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,13 +1,9 @@
|
||||
# Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml
|
||||
|
||||
startCommand:
|
||||
type: stdio
|
||||
type: http
|
||||
configSchema:
|
||||
# JSON Schema defining the configuration options for the MCP.
|
||||
type: object
|
||||
description: Empty configuration
|
||||
commandFunction:
|
||||
# A JS function that produces the CLI command based on the given config to start the MCP on stdio.
|
||||
|-
|
||||
(config) => ({ command: 'node', args: ['dist/index.js'] })
|
||||
description: No configuration required
|
||||
exampleConfig: {}
|
||||
|
391
src/index.ts
391
src/index.ts
@ -5,169 +5,292 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
||||
import { z } from "zod";
|
||||
import { searchLibraries, fetchLibraryDocumentation } from "./lib/api.js";
|
||||
import { formatSearchResults } from "./lib/utils.js";
|
||||
import dotenv from "dotenv";
|
||||
import { SearchResponse } from "./lib/types.js";
|
||||
import { createServer } from "http";
|
||||
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
||||
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
||||
import { Command } from "commander";
|
||||
|
||||
// Load environment variables from .env file if present
|
||||
dotenv.config();
|
||||
const DEFAULT_MINIMUM_TOKENS = 10000;
|
||||
|
||||
// Get DEFAULT_MINIMUM_TOKENS from environment variable or use default
|
||||
let DEFAULT_MINIMUM_TOKENS = 10000;
|
||||
if (process.env.DEFAULT_MINIMUM_TOKENS) {
|
||||
const parsedValue = parseInt(process.env.DEFAULT_MINIMUM_TOKENS, 10);
|
||||
if (!isNaN(parsedValue) && parsedValue > 0) {
|
||||
DEFAULT_MINIMUM_TOKENS = parsedValue;
|
||||
} else {
|
||||
console.warn(
|
||||
`Warning: Invalid DEFAULT_MINIMUM_TOKENS value provided in environment variable. Using default value of 10000`
|
||||
);
|
||||
}
|
||||
// Parse CLI arguments using commander
|
||||
const program = new Command()
|
||||
.option("--transport <stdio|http|sse>", "transport type", "stdio")
|
||||
.option("--port <number>", "port for HTTP/SSE transport", "3000")
|
||||
.allowUnknownOption() // let MCP Inspector / other wrappers pass through extra flags
|
||||
.parse(process.argv);
|
||||
|
||||
const cliOptions = program.opts<{
|
||||
transport: string;
|
||||
port: string;
|
||||
}>();
|
||||
|
||||
// Validate transport option
|
||||
const allowedTransports = ["stdio", "http", "sse"];
|
||||
if (!allowedTransports.includes(cliOptions.transport)) {
|
||||
console.error(
|
||||
`Invalid --transport value: '${cliOptions.transport}'. Must be one of: stdio, http, sse.`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Create server instance
|
||||
const server = new McpServer({
|
||||
name: "Context7",
|
||||
description: "Retrieves up-to-date documentation and code examples for any library.",
|
||||
version: "1.0.6",
|
||||
capabilities: {
|
||||
resources: {},
|
||||
tools: {},
|
||||
},
|
||||
});
|
||||
// Transport configuration
|
||||
const TRANSPORT_TYPE = (cliOptions.transport || "stdio") as "stdio" | "http" | "sse";
|
||||
|
||||
// Register Context7 tools
|
||||
server.tool(
|
||||
"resolve-library-id",
|
||||
`Resolves a package name to a Context7-compatible library ID and returns a list of matching libraries.
|
||||
// HTTP/SSE port configuration
|
||||
const CLI_PORT = (() => {
|
||||
const parsed = parseInt(cliOptions.port, 10);
|
||||
return isNaN(parsed) ? undefined : parsed;
|
||||
})();
|
||||
|
||||
You MUST call this function before 'get-library-docs' to obtain a valid Context7-compatible library ID.
|
||||
// Store SSE transports by session ID
|
||||
const sseTransports: Record<string, SSEServerTransport> = {};
|
||||
|
||||
When selecting the best match, consider:
|
||||
- Name similarity to the query
|
||||
- Description relevance
|
||||
- Code Snippet count (documentation coverage)
|
||||
- GitHub Stars (popularity)
|
||||
// Function to create a new server instance with all tools registered
|
||||
function createServerInstance() {
|
||||
const server = new McpServer(
|
||||
{
|
||||
name: "Context7",
|
||||
version: "1.0.13",
|
||||
},
|
||||
{
|
||||
instructions:
|
||||
"Use this server to retrieve up-to-date documentation and code examples for any library.",
|
||||
}
|
||||
);
|
||||
|
||||
Return the selected library ID and explain your choice. If there are multiple good matches, mention this but proceed with the most relevant one.`,
|
||||
{
|
||||
libraryName: z
|
||||
.string()
|
||||
.describe("Library name to search for and retrieve a Context7-compatible library ID."),
|
||||
},
|
||||
async ({ libraryName }) => {
|
||||
const searchResponse = await searchLibraries(libraryName);
|
||||
// Register Context7 tools
|
||||
server.tool(
|
||||
"resolve-library-id",
|
||||
`Resolves a package/product name to a Context7-compatible library ID and returns a list of matching libraries.
|
||||
|
||||
You MUST call this function before 'get-library-docs' to obtain a valid Context7-compatible library ID UNLESS the user explicitly provides a library ID in the format '/org/project' or '/org/project/version' in their query.
|
||||
|
||||
Selection Process:
|
||||
1. Analyze the query to understand what library/package the user is looking for
|
||||
2. Return the most relevant match based on:
|
||||
- Name similarity to the query (exact matches prioritized)
|
||||
- Description relevance to the query's intent
|
||||
- Documentation coverage (prioritize libraries with higher Code Snippet counts)
|
||||
- Trust score (consider libraries with scores of 7-10 more authoritative)
|
||||
|
||||
Response Format:
|
||||
- Return the selected library ID in a clearly marked section
|
||||
- Provide a brief explanation for why this library was chosen
|
||||
- If multiple good matches exist, acknowledge this but proceed with the most relevant one
|
||||
- If no good matches exist, clearly state this and suggest query refinements
|
||||
|
||||
For ambiguous queries, request clarification before proceeding with a best-guess match.`,
|
||||
{
|
||||
libraryName: z
|
||||
.string()
|
||||
.describe("Library name to search for and retrieve a Context7-compatible library ID."),
|
||||
},
|
||||
async ({ libraryName }) => {
|
||||
const searchResponse: SearchResponse = await searchLibraries(libraryName);
|
||||
|
||||
if (!searchResponse.results || searchResponse.results.length === 0) {
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: searchResponse.error
|
||||
? searchResponse.error
|
||||
: "Failed to retrieve library documentation data from Context7",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const resultsText = formatSearchResults(searchResponse);
|
||||
|
||||
if (!searchResponse || !searchResponse.results) {
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Failed to retrieve library documentation data from Context7",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
if (searchResponse.results.length === 0) {
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "No documentation libraries available",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const resultsText = formatSearchResults(searchResponse);
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: `Available Libraries (top matches):
|
||||
text: `Available Libraries (top matches):
|
||||
|
||||
Each result includes:
|
||||
- Library ID: Context7-compatible identifier (format: /org/repo)
|
||||
- Library ID: Context7-compatible identifier (format: /org/project)
|
||||
- Name: Library or package name
|
||||
- Description: Short summary
|
||||
- Code Snippets: Number of available code examples
|
||||
- GitHub Stars: Popularity indicator
|
||||
- Trust Score: Authority indicator
|
||||
- Versions: List of versions if available. Use one of those versions if and only if the user explicitly provides a version in their query.
|
||||
|
||||
For best results, select libraries based on name match, popularity (stars), snippet coverage, and relevance to your use case.
|
||||
For best results, select libraries based on name match, trust score, snippet coverage, and relevance to your use case.
|
||||
|
||||
---
|
||||
----------
|
||||
|
||||
${resultsText}`,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
server.tool(
|
||||
"get-library-docs",
|
||||
"Fetches up-to-date documentation for a library. You must call 'resolve-library-id' first to obtain the exact Context7-compatible library ID required to use this tool.",
|
||||
{
|
||||
context7CompatibleLibraryID: z
|
||||
.string()
|
||||
.describe(
|
||||
"Exact Context7-compatible library ID (e.g., 'mongodb/docs', 'vercel/nextjs') retrieved from 'resolve-library-id'."
|
||||
),
|
||||
topic: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Topic to focus documentation on (e.g., 'hooks', 'routing')."),
|
||||
tokens: z
|
||||
.preprocess((val) => (typeof val === "string" ? Number(val) : val), z.number())
|
||||
.transform((val) => (val < DEFAULT_MINIMUM_TOKENS ? DEFAULT_MINIMUM_TOKENS : val))
|
||||
.optional()
|
||||
.describe(
|
||||
`Maximum number of tokens of documentation to retrieve (default: ${DEFAULT_MINIMUM_TOKENS}). Higher values provide more context but consume more tokens.`
|
||||
),
|
||||
},
|
||||
async ({ context7CompatibleLibraryID, tokens = DEFAULT_MINIMUM_TOKENS, topic = "" }) => {
|
||||
// Extract folders parameter if present in the ID
|
||||
let folders = "";
|
||||
let libraryId = context7CompatibleLibraryID;
|
||||
|
||||
if (context7CompatibleLibraryID.includes("?folders=")) {
|
||||
const [id, foldersParam] = context7CompatibleLibraryID.split("?folders=");
|
||||
libraryId = id;
|
||||
folders = foldersParam;
|
||||
}
|
||||
|
||||
const documentationText = await fetchLibraryDocumentation(libraryId, {
|
||||
tokens,
|
||||
topic,
|
||||
folders,
|
||||
});
|
||||
|
||||
if (!documentationText) {
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Documentation not found or not finalized for this library. This might have happened because you used an invalid Context7-compatible library ID. To get a valid Context7-compatible library ID, use the 'resolve-library-id' with the package name you wish to retrieve documentation for.",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: documentationText,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
);
|
||||
server.tool(
|
||||
"get-library-docs",
|
||||
"Fetches up-to-date documentation for a library. You must call 'resolve-library-id' first to obtain the exact Context7-compatible library ID required to use this tool, UNLESS the user explicitly provides a library ID in the format '/org/project' or '/org/project/version' in their query.",
|
||||
{
|
||||
context7CompatibleLibraryID: z
|
||||
.string()
|
||||
.describe(
|
||||
"Exact Context7-compatible library ID (e.g., '/mongodb/docs', '/vercel/next.js', '/supabase/supabase', '/vercel/next.js/v14.3.0-canary.87') retrieved from 'resolve-library-id' or directly from user query in the format '/org/project' or '/org/project/version'."
|
||||
),
|
||||
topic: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Topic to focus documentation on (e.g., 'hooks', 'routing')."),
|
||||
tokens: z
|
||||
.preprocess((val) => (typeof val === "string" ? Number(val) : val), z.number())
|
||||
.transform((val) => (val < DEFAULT_MINIMUM_TOKENS ? DEFAULT_MINIMUM_TOKENS : val))
|
||||
.optional()
|
||||
.describe(
|
||||
`Maximum number of tokens of documentation to retrieve (default: ${DEFAULT_MINIMUM_TOKENS}). Higher values provide more context but consume more tokens.`
|
||||
),
|
||||
},
|
||||
async ({ context7CompatibleLibraryID, tokens = DEFAULT_MINIMUM_TOKENS, topic = "" }) => {
|
||||
const fetchDocsResponse = await fetchLibraryDocumentation(context7CompatibleLibraryID, {
|
||||
tokens,
|
||||
topic,
|
||||
});
|
||||
|
||||
if (!fetchDocsResponse) {
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Documentation not found or not finalized for this library. This might have happened because you used an invalid Context7-compatible library ID. To get a valid Context7-compatible library ID, use the 'resolve-library-id' with the package name you wish to retrieve documentation for.",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: fetchDocsResponse,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const transport = new StdioServerTransport();
|
||||
await server.connect(transport);
|
||||
console.error("Context7 Documentation MCP Server running on stdio");
|
||||
const transportType = TRANSPORT_TYPE;
|
||||
|
||||
if (transportType === "http" || transportType === "sse") {
|
||||
// Get initial port from environment or use default
|
||||
const initialPort = CLI_PORT ?? 3000;
|
||||
// Keep track of which port we end up using
|
||||
let actualPort = initialPort;
|
||||
const httpServer = createServer(async (req, res) => {
|
||||
const url = new URL(req.url || "", `http://${req.headers.host}`).pathname;
|
||||
|
||||
// Set CORS headers for all responses
|
||||
res.setHeader("Access-Control-Allow-Origin", "*");
|
||||
res.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS,DELETE");
|
||||
res.setHeader("Access-Control-Allow-Headers", "Content-Type, MCP-Session-Id, mcp-session-id");
|
||||
|
||||
// Handle preflight OPTIONS requests
|
||||
if (req.method === "OPTIONS") {
|
||||
res.writeHead(200);
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Create new server instance for each request
|
||||
const requestServer = createServerInstance();
|
||||
|
||||
if (url === "/mcp") {
|
||||
const transport = new StreamableHTTPServerTransport({
|
||||
sessionIdGenerator: undefined,
|
||||
});
|
||||
await requestServer.connect(transport);
|
||||
await transport.handleRequest(req, res);
|
||||
} else if (url === "/sse" && req.method === "GET") {
|
||||
// Create new SSE transport for GET request
|
||||
const sseTransport = new SSEServerTransport("/messages", res);
|
||||
// Store the transport by session ID
|
||||
sseTransports[sseTransport.sessionId] = sseTransport;
|
||||
// Clean up transport when connection closes
|
||||
res.on("close", () => {
|
||||
delete sseTransports[sseTransport.sessionId];
|
||||
});
|
||||
await requestServer.connect(sseTransport);
|
||||
} else if (url === "/messages" && req.method === "POST") {
|
||||
// Get session ID from query parameters
|
||||
const sessionId =
|
||||
new URL(req.url || "", `http://${req.headers.host}`).searchParams.get("sessionId") ??
|
||||
"";
|
||||
|
||||
if (!sessionId) {
|
||||
res.writeHead(400);
|
||||
res.end("Missing sessionId parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get existing transport for this session
|
||||
const sseTransport = sseTransports[sessionId];
|
||||
if (!sseTransport) {
|
||||
res.writeHead(400);
|
||||
res.end(`No transport found for sessionId: ${sessionId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle the POST message with the existing transport
|
||||
await sseTransport.handlePostMessage(req, res);
|
||||
} else if (url === "/ping") {
|
||||
res.writeHead(200, { "Content-Type": "text/plain" });
|
||||
res.end("pong");
|
||||
} else {
|
||||
res.writeHead(404);
|
||||
res.end("Not found");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error handling request:", error);
|
||||
if (!res.headersSent) {
|
||||
res.writeHead(500);
|
||||
res.end("Internal Server Error");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Function to attempt server listen with port fallback
|
||||
const startServer = (port: number, maxAttempts = 10) => {
|
||||
httpServer.once("error", (err: NodeJS.ErrnoException) => {
|
||||
if (err.code === "EADDRINUSE" && port < initialPort + maxAttempts) {
|
||||
console.warn(`Port ${port} is in use, trying port ${port + 1}...`);
|
||||
startServer(port + 1, maxAttempts);
|
||||
} else {
|
||||
console.error(`Failed to start server: ${err.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
httpServer.listen(port, () => {
|
||||
actualPort = port;
|
||||
console.error(
|
||||
`Context7 Documentation MCP Server running on ${transportType.toUpperCase()} at http://localhost:${actualPort}/mcp and legacy SSE at /sse`
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
// Start the server with initial port
|
||||
startServer(initialPort);
|
||||
} else {
|
||||
// Stdio transport - this is already stateless by nature
|
||||
const server = createServerInstance();
|
||||
const transport = new StdioServerTransport();
|
||||
await server.connect(transport);
|
||||
console.error("Context7 Documentation MCP Server running on stdio");
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
|
@ -8,19 +8,30 @@ const DEFAULT_TYPE = "txt";
|
||||
* @param query The search query
|
||||
* @returns Search results or null if the request fails
|
||||
*/
|
||||
export async function searchLibraries(query: string): Promise<SearchResponse | null> {
|
||||
export async function searchLibraries(query: string): Promise<SearchResponse> {
|
||||
try {
|
||||
const url = new URL(`${CONTEXT7_API_BASE_URL}/v1/search`);
|
||||
url.searchParams.set("query", query);
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
console.error(`Failed to search libraries: ${response.status}`);
|
||||
return null;
|
||||
const errorCode = response.status;
|
||||
if (errorCode === 429) {
|
||||
console.error(`Rate limited due to too many requests. Please try again later.`);
|
||||
return {
|
||||
results: [],
|
||||
error: `Rate limited due to too many requests. Please try again later.`,
|
||||
} as SearchResponse;
|
||||
}
|
||||
console.error(`Failed to search libraries. Please try again later. Error code: ${errorCode}`);
|
||||
return {
|
||||
results: [],
|
||||
error: `Failed to search libraries. Please try again later. Error code: ${errorCode}`,
|
||||
} as SearchResponse;
|
||||
}
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error("Error searching libraries:", error);
|
||||
return null;
|
||||
return { results: [], error: `Error searching libraries: ${error}` } as SearchResponse;
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +46,6 @@ export async function fetchLibraryDocumentation(
|
||||
options: {
|
||||
tokens?: number;
|
||||
topic?: string;
|
||||
folders?: string;
|
||||
} = {}
|
||||
): Promise<string | null> {
|
||||
try {
|
||||
@ -45,7 +55,6 @@ export async function fetchLibraryDocumentation(
|
||||
const url = new URL(`${CONTEXT7_API_BASE_URL}/v1/${libraryId}`);
|
||||
if (options.tokens) url.searchParams.set("tokens", options.tokens.toString());
|
||||
if (options.topic) url.searchParams.set("topic", options.topic);
|
||||
if (options.folders) url.searchParams.set("folders", options.folders);
|
||||
url.searchParams.set("type", DEFAULT_TYPE);
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
@ -53,8 +62,15 @@ export async function fetchLibraryDocumentation(
|
||||
},
|
||||
});
|
||||
if (!response.ok) {
|
||||
console.error(`Failed to fetch documentation: ${response.status}`);
|
||||
return null;
|
||||
const errorCode = response.status;
|
||||
if (errorCode === 429) {
|
||||
const errorMessage = `Rate limited due to too many requests. Please try again later.`;
|
||||
console.error(errorMessage);
|
||||
return errorMessage;
|
||||
}
|
||||
const errorMessage = `Failed to fetch documentation. Please try again later. Error code: ${errorCode}`;
|
||||
console.error(errorMessage);
|
||||
return errorMessage;
|
||||
}
|
||||
const text = await response.text();
|
||||
if (!text || text === "No content available" || text === "No context data available") {
|
||||
@ -62,7 +78,8 @@ export async function fetchLibraryDocumentation(
|
||||
}
|
||||
return text;
|
||||
} catch (error) {
|
||||
console.error("Error fetching library documentation:", error);
|
||||
return null;
|
||||
const errorMessage = `Error fetching library documentation. Please try again later. ${error}`;
|
||||
console.error(errorMessage);
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,20 @@
|
||||
export interface SearchResult {
|
||||
id: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
description: string;
|
||||
branch: string;
|
||||
lastUpdate: string;
|
||||
lastUpdateDate: string;
|
||||
state: DocumentState;
|
||||
totalTokens: number;
|
||||
totalSnippets: number;
|
||||
totalPages: number;
|
||||
stars: number;
|
||||
stars?: number;
|
||||
trustScore?: number;
|
||||
versions?: string[];
|
||||
}
|
||||
|
||||
export interface SearchResponse {
|
||||
error?: string;
|
||||
results: SearchResult[];
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,45 @@
|
||||
import { SearchResponse, SearchResult } from "./types.js";
|
||||
|
||||
/**
|
||||
* Format a search result into a string representation
|
||||
* @param result SearchResult to format
|
||||
* @returns Formatted search result string
|
||||
* Formats a search result into a human-readable string representation.
|
||||
* Only shows code snippet count and GitHub stars when available (not equal to -1).
|
||||
*
|
||||
* @param result The SearchResult object to format
|
||||
* @returns A formatted string with library information
|
||||
*/
|
||||
export function formatSearchResult(result: SearchResult): string {
|
||||
return `- Title: ${result.title}
|
||||
- Context7-compatible library ID: ${result.id}
|
||||
- Description: ${result.description}
|
||||
- Code Snippets: ${result.totalSnippets}
|
||||
- GitHub Stars: ${result.stars}`;
|
||||
// Always include these basic details
|
||||
const formattedResult = [
|
||||
`- Title: ${result.title}`,
|
||||
`- Context7-compatible library ID: ${result.id}`,
|
||||
`- Description: ${result.description}`,
|
||||
];
|
||||
|
||||
// Only add code snippets count if it's a valid value
|
||||
if (result.totalSnippets !== -1 && result.totalSnippets !== undefined) {
|
||||
formattedResult.push(`- Code Snippets: ${result.totalSnippets}`);
|
||||
}
|
||||
|
||||
// Only add trust score if it's a valid value
|
||||
if (result.trustScore !== -1 && result.trustScore !== undefined) {
|
||||
formattedResult.push(`- Trust Score: ${result.trustScore}`);
|
||||
}
|
||||
|
||||
// Only add versions if it's a valid value
|
||||
if (result.versions !== undefined && result.versions.length > 0) {
|
||||
formattedResult.push(`- Versions: ${result.versions.join(", ")}`);
|
||||
}
|
||||
|
||||
// Join all parts with newlines
|
||||
return formattedResult.join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Format search results into a string representation
|
||||
* @param searchResponse The search response to format
|
||||
* @returns Formatted search results string
|
||||
* Formats a search response into a human-readable string representation.
|
||||
* Each result is formatted using formatSearchResult.
|
||||
*
|
||||
* @param searchResponse The SearchResponse object to format
|
||||
* @returns A formatted string with search results
|
||||
*/
|
||||
export function formatSearchResults(searchResponse: SearchResponse): string {
|
||||
if (!searchResponse.results || searchResponse.results.length === 0) {
|
||||
@ -24,5 +47,5 @@ export function formatSearchResults(searchResponse: SearchResponse): string {
|
||||
}
|
||||
|
||||
const formattedResults = searchResponse.results.map(formatSearchResult);
|
||||
return formattedResults.join("\n---\n");
|
||||
return formattedResults.join("\n----------\n");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user