feat: support FOFA_EMAIL/FOFA_KEY environment variables in mcp.json - #40
Open
LilyAva000 wants to merge 1 commit into
Open
feat: support FOFA_EMAIL/FOFA_KEY environment variables in mcp.json#40LilyAva000 wants to merge 1 commit into
LilyAva000 wants to merge 1 commit into
Conversation
Allow configuring FOFA credentials via environment variables in mcp.json "env" field, so users no longer have to put credentials in config/settings.yaml. Environment variables take precedence over the yaml config; the yaml file remains the fallback when env vars are unset. - config/__init__.py: override userinfo.email/key from FOFA_EMAIL and FOFA_KEY after loading settings.yaml - README.md: document the env option with a complete mcp.json example
Owner
|
感谢提交这个 PR,也感谢你指出 MCP 场景下不应强制把 FOFA 凭据写进项目配置文件。 经对照确认,这个需求已经在正式发布的 v2.0.1 中覆盖,而且安全边界比本 PR 基于 v2.0.0 的实现更完整,因此不再需要合并当前补丁:
因此,在支持 另外,本 PR 的目标分支仍是旧的 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景 (Motivation)
目前 FofaMap 的 MCP 服务只能通过
config/settings.yaml配置 FOFA 凭据,不支持在mcp.json的env字段中传入。这带来两个不便:env注入凭据);改动内容 (Changes)
config/__init__.py:在加载settings.yaml之后,读取环境变量FOFA_EMAIL和FOFA_KEY并覆盖userinfo.email/userinfo.key。环境变量优先级高于 yaml 配置;未设置环境变量时行为与之前完全一致(向后兼容)。由于 CLI 与 MCP 共用settings单例,CLI 模式下同样生效。README.md:在 Cursor / LM Studio 的 MCP 集成章节中补充env配置说明,并给出完整的mcp.json参考示例:{ "mcpServers": { "fofamap-v2": { "command": "python3.10", "args": ["/path/to/mcp_server.py"], "env": { "FOFA_EMAIL": "your_email@example.com", "FOFA_KEY": "your_fofa_api_key" } } } }测试 (Testing)
已验证以下三种场景:
settings.yaml中的 email/key(行为不变)FOFA_EMAIL+FOFA_KEY兼容性
完全向后兼容:不设置环境变量时,加载逻辑与改动前一致,
settings.yaml仍是必需的(其余配置项仍从 yaml 读取)。