fofa-mcp CLAUDE.md

fofa-mcp CLAUDE.md is an instructions file for coding agents from lulaide/fofa-mcp. It costs 854 tokens per session, scanned A, original, MIT.

Repository instructions for fofa-mcp, a service that connects coding agents to FOFA search functions. They describe local standard-input mode, an HTTP server mode, and a Cloudflare Worker deployment.

In plain words
What is it for?
Use them to build or run fofa-mcp locally, as an HTTP service, or on Cloudflare Workers. They also cover OAuth authentication, token handling, worker development, and conditional tool registration.
Why use it?
They explain how to build and run the service in each deployment style, including authentication, configuration, and which tools are available for official or custom FOFA endpoints.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/lulaide/fofa-mcp/claude-md
Clone the repo
git clone --depth 1 https://github.com/lulaide/fofa-mcp

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for fofa-mcp CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/lulaide/fofa-mcp/claude-md.svg)](https://agentmods.dev/instructions/lulaide/fofa-mcp/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/lulaide/fofa-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/lulaide/fofa-mcp/claude-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 854 This file is loaded in full into every session.
When invoked 854 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00854 $0.00854
Opus 5 $0.00427 $0.00427
Sonnet 5 $0.00171 $0.00171
Haiku 4.5 $0.00085 $0.00085

Measured 5d ago against content hash 4c57e3787043, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

fofa-mcp CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 72 lines

How it starts

The opening of the file, as written. The whole thing — 72 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

构建与运行

# 构建
npm run build

# stdio 模式(默认,本地客户端用)
node dist/index.js

# HTTP 模式(远程部署,Claude.ai 网页端用)
JWE_SECRET=... JWS_SECRET=... SERVER_URL=http://localhost:3000 node dist/index.js serve

# Worker(独立项目,在 worker/ 目录下)
cd worker && npm run dev      # 本地开发
cd worker && npm run deploy   # 部署到 Cloudflare

架构

项目有三种运行模式:

  1. stdiofofa-mcp)— 本地 MCP,通过 stdin/stdout 通信,配置来自环境变量
  2. servefofa-mcp serve)— Express HTTP 服务器,OAuth 2.1 + PKCE 认证,配置来自 JWT token
  3. workerworker/)— Cloudflare Worker 无服务器部署,同样的 OAuth 流程,使用 Web Standard API

完全无状态 HTTP

serveworker 都是无状态的——每个 POST /mcp 请求独立创建 McpServer + Transport,处理完即销毁。无 session,无跨请求内存状态。用户的 FOFA 配置(baseURL + apiKey)存在 JWS access token 中。

条件工具注册

isOfficialAPI(baseURL) 控制 fofa_user_infofofa_statsfofa_host 是否注册——这些只在官方 fofa.info 上可用。自定义/中转 API 地址只注册 fofa_search + fofa_export

OAuth token 流程(serve 和 worker)

  • authorization code:JWE 加密(A256GCM),包含用户 FOFA 配置 + PKCE challenge,5 分钟过期
  • access token:JWS 签名(HS256),包含 FOFA 配置,365 天过期
  • 密钥未设置时自动随机生成(重启后旧 token 失效)

代码结构

  • src/index.ts — CLI 分发:process.argv[2] === "serve" 进入 HTTP 模式
  • src/client.ts — FOFA API 客户端(searchuserInfostatshostDetail)+ 环境变量配置加载
  • src/tools/ — 每个文件导出 register*Tool(server, config) 函数
  • src/server/create-mcp-server.ts — 共享工厂函数,stdio 和 serve 模式都用
  • src/server/serve.ts — Express 应用,挂载 SDK 的 mcpAuthRouter + 无状态 /mcp 处理
  • src/server/crypto.tsjose 库的 JWE/JWS 封装
  • src/server/oauth-provider.ts — 实现 SDK 的 OAuthServerProvider 接口
  • worker/ — 独立项目,不依赖 Express,纯 fetch handler 实现 OAuth + MCP

发布流程

推送 v* 标签 → CI 自动发布 npm + 创建 GitHub Release:

# 更新 package.json 和 src/server/create-mcp-server.ts 中的版本号
git tag -a v0.x.x -m "描述"
git push origin main v0.x.x

Worker 独立部署:cd worker && npx wrangler deploy

约定

  • 提交信息:conventional commits 中文(如 feat: 新增...fix: 修复...
  • npm 包只发布 dist/ 编译产物
  • Worker 启用 nodejs_compat 兼容标志

Read the full file on GitHub · 72 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 72 lines · 854 tokens per session scan A 4c57e3787043

Subscribe to this mod's changes

fofa-mcp CLAUDE.md is an instructions file published in the GitHub repository lulaide/fofa-mcp (11 stars, last pushed 5mo ago), licensed MIT. It adds 854 tokens to every session, about $0.0043 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories

next.js AGENTS.md

AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,296 tokens

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,182 tokens

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 6,785 tokens

spec-kit AGENTS.md

AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.

github/spec-kit · 7,104 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,469 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens