Skip to content

用SpringAI实现一个MCP Server,怎么接收客户端传递过来的env #3330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
baigod opened this issue May 26, 2025 · 5 comments
Open

Comments

@baigod
Copy link

baigod commented May 26, 2025

我用cursor的settings配置了一个mcp.json,配置如下:

Image

我的本地服务,使用SrpingAI的@tool来注册工具,那么我这个工具怎么获取到cursor中配置的env参数PM-ID呢?

@lghgf123
Copy link

env是 stdio那种本地启动的,env就是修改你电脑的环境变量,所以sse方式,远程访问是无法获取到的

@luguangdong
Copy link

Image

Image
可以将环境参数设置到 version 版本字段中,这样就可以在服务端获取到你的env参数了。

@ai-srcflow
Copy link

stdio 直接代码 注入获取 getEnv 就行了

@gelicchen
Copy link

自定义HandlerInterceptor解析env并将其放到InheritableThreadLocal中,再讲其注册到WebMvcConfigurer的addInterceptors中;使用时从InheritableThreadLocal中获取

@xulisha123
Copy link

你但凡听一下徐庶老师我讲的 MCP鉴权你都不会问这个问题:https://www.bilibili.com/video/BV1ir55zQEsF/?spm_id_from=333.337.search-card.all.click

mcp server端直接 System.getenv("PM-ID")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants