请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

我在git上同样的代码为什么我执行有报错,server也可以单独运行

报错如下:(反馈没有mcp的模型)
Traceback (most recent call last):
File “/Users/kentbernard/PythonProject/ai-pythone12/app/mcp/stdio/mcp_stdio_server.py”, line 1, in
from mcp.server.fastmcp import FastMCP
ModuleNotFoundError: No module named ‘mcp’

  • Exception Group Traceback (most recent call last):
    | File “/Users/kentbernard/PythonProject/ai-pythone12/app/mcp/stdio/mcp_stdio_client.py”, line 19, in
    | asyncio.run(create_mcp_stdio_client())
    | File “/opt/anaconda3/envs/python12/lib/python3.12/asyncio/runners.py”, line 195, in run
    | return runner.run(main)
    | ^^^^^^^^^^^^^^^^
    | File “/opt/anaconda3/envs/python12/lib/python3.12/asyncio/runners.py”, line 118, in run
    | return self._loop.run_until_complete(task)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File “/opt/anaconda3/envs/python12/lib/python3.12/asyncio/base_events.py”, line 691, in run_until_complete
    | return future.result()
    | ^^^^^^^^^^^^^^^
    | File “/Users/kentbernard/PythonProject/ai-pythone12/app/mcp/stdio/mcp_stdio_client.py”, line 13, in create_mcp_stdio_client
    | async with stdio_client(server_params) as (read, write):
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File “/opt/anaconda3/envs/python12/lib/python3.12/contextlib.py”, line 231, in aexit
    | await self.gen.athrow(value)
    | File “/Users/kentbernard/PythonProject/ai-pythone12/.venv/lib/python3.12/site-packages/mcp/client/stdio/init.py”, line 183, in stdio_client
    | anyio.create_task_group() as tg,
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
    | File “/Users/kentbernard/PythonProject/ai-pythone12/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py”, line 783, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    ±±--------------- 1 ----------------
    | Exception Group Traceback (most recent call last):
    | File “/Users/kentbernard/PythonProject/ai-pythone12/.venv/lib/python3.12/site-packages/mcp/client/stdio/init.py”, line 189, in stdio_client
    | yield read_stream, write_stream
    | File “/Users/kentbernard/PythonProject/ai-pythone12/app/mcp/stdio/mcp_stdio_client.py”, line 14, in create_mcp_stdio_client
    | async with ClientSession(read, write) as session:
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File “/Users/kentbernard/PythonProject/ai-pythone12/.venv/lib/python3.12/site-packages/mcp/shared/session.py”, line 238, in aexit
    | return await self._task_group.aexit(exc_type, exc_val, exc_tb)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File “/Users/kentbernard/PythonProject/ai-pythone12/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py”, line 783, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    ±±--------------- 1 ----------------
    | Traceback (most recent call last):
    | File “/Users/kentbernard/PythonProject/ai-pythone12/app/mcp/stdio/mcp_stdio_client.py”, line 15, in create_mcp_stdio_client
    | await session.initialize()
    | File “/Users/kentbernard/PythonProject/ai-pythone12/.venv/lib/python3.12/site-packages/mcp/client/session.py”, line 171, in initialize
    | result = await self.send_request(
    | ^^^^^^^^^^^^^^^^^^^^^^^^
    | File “/Users/kentbernard/PythonProject/ai-pythone12/.venv/lib/python3.12/site-packages/mcp/shared/session.py”, line 306, in send_request
    | raise McpError(response_or_error.error)
    | mcp.shared.exceptions.McpError: Connection closed
    ±-----------------------------------

正在回答

2回答

pip install mcp

0 回复 有任何疑惑可以回复我~
  • 提问者 博圣慕课 #1
    装了,没用
    回复 有任何疑惑可以回复我~ 2026-01-04 15:01:48
  • 提问者 博圣慕课 #2
    pip list 有这个mcp.
    回复 有任何疑惑可以回复我~ 2026-01-04 15:07:12
  • 提问者 博圣慕课 #3
    ok了
    回复 有任何疑惑可以回复我~ 2026-01-04 15:22:23
Sam 2026-01-04 14:58:09

根据报错提示没安装mcp包

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号