context7
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecontext7
context7
Use this skill when you need to work with context7 through its generated async Python app, call its MCP-backed functions from code, or inspect available functions with the mcp-skill CLI.
当你需要通过其生成的异步Python应用来使用context7、从代码中调用其基于MCP的函数,或者使用mcp-skill CLI查看可用函数时,请使用此技能。
Authentication
身份验证
No authentication required.
python
app = Context7App()Passing an argument is accepted but has no effect and will emit a warning.
auth无需身份验证。
python
app = Context7App()传入参数是被允许的,但不会产生任何效果,并且会发出警告。
authDependencies
依赖项
This skill requires the following Python packages:
mcp-skill
Install with uv:
bash
uv pip install mcp-skillOr with pip:
bash
pip install mcp-skill此技能需要以下Python包:
mcp-skill
使用uv安装:
bash
uv pip install mcp-skill或者使用pip安装:
bash
pip install mcp-skillPython Usage
Python使用方法
Use the generated app directly in async Python code:
python
import asyncio
from context7.app import Context7App
async def main():
app = Context7App()
result = await app.resolve_library_id(query="example", libraryName="example")
print(result)
asyncio.run(main())在异步Python代码中直接使用生成的应用:
python
import asyncio
from context7.app import Context7App
async def main():
app = Context7App()
result = await app.resolve_library_id(query="example", libraryName="example")
print(result)
asyncio.run(main())Async Usage Notes
异步使用注意事项
- Every generated tool method is , so call it with
async.await - Use these apps inside an async function, then run that function with if you are in a script.
asyncio.run(...) - If you forget , you will get a coroutine object instead of the actual tool result.
await - Be careful when mixing this with other event-loop environments such as notebooks, web servers, or async frameworks.
- 每个生成的工具方法都是的,因此请使用
async调用它。await - 在异步函数中使用这些应用,如果是在脚本中,请使用运行该函数。
asyncio.run(...) - 如果你忘记使用,你将得到一个协程对象而不是实际的工具结果。
await - 当将其与其他事件循环环境(如笔记本、Web服务器或异步框架)混合使用时要小心。
Discover Functions with the CLI
使用CLI发现函数
Use the CLI to find available apps, list functions on an app, and inspect a function before calling it:
bash
uvx mcp-skill list-apps
uvx mcp-skill list-functions context7
uvx mcp-skill inspect context7 resolve_library_idImportant: Add to your Python path so imports resolve correctly:
.agents/skillspython
import sys
sys.path.insert(0, ".agents/skills")
from context7.app import Context7AppOr set the environment variable:
PYTHONPATHbash
export PYTHONPATH=".agents/skills:$PYTHONPATH"Preferred: use (handles dependencies automatically):
uv runbash
PYTHONPATH=.agents/skills uv run --with mcp-skill python -c "
import asyncio
from context7.app import Context7App
async def main():
app = Context7App()
result = await app.resolve_library_id(query="example", libraryName="example")
print(result)
asyncio.run(main())
"Alternative: use directly (install dependencies first):
pythonbash
pip install mcp-skill
PYTHONPATH=.agents/skills python -c "
import asyncio
from context7.app import Context7App
async def main():
app = Context7App()
result = await app.resolve_library_id(query="example", libraryName="example")
print(result)
asyncio.run(main())
"使用CLI查找可用应用、列出应用上的函数,并在调用函数前查看其信息:
bash
uvx mcp-skill list-apps
uvx mcp-skill list-functions context7
uvx mcp-skill inspect context7 resolve_library_id重要提示: 将添加到你的Python路径中,以便正确解析导入:
.agents/skillspython
import sys
sys.path.insert(0, ".agents/skills")
from context7.app import Context7App或者设置环境变量:
PYTHONPATHbash
export PYTHONPATH=".agents/skills:$PYTHONPATH"推荐:使用(自动处理依赖项):
uv runbash
PYTHONPATH=.agents/skills uv run --with mcp-skill python -c "
import asyncio
from context7.app import Context7App
async def main():
app = Context7App()
result = await app.resolve_library_id(query=\"example\", libraryName=\"example\")
print(result)
asyncio.run(main())
"替代方案:直接使用(先安装依赖项):
pythonbash
pip install mcp-skill
PYTHONPATH=.agents/skills python -c "
import asyncio
from context7.app import Context7App
async def main():
app = Context7App()
result = await app.resolve_library_id(query=\"example\", libraryName=\"example\")
print(result)
asyncio.run(main())
"