
legacy2mcp
io.github.bvenkata由 GitHub 账号 bvenkata 发布v0.5.1更新于 Nov 6, 2026
Turn a legacy SOAP/WSDL, database, or REST API into a safe, typed, audit-logged MCP server
概览
把遗留的 SOAP/WSDL、数据库或 REST API 转成带类型校验和审计日志的 MCP 服务器,供助手调用。
- 可以做什么
- 从 WSDL 地址、REST/OpenAPI 地址、爬取的网站或 GitHub/源码扫描生成配置
- 检查配置并以 JSON 列出生成的工具,便于审阅或 CI 比对
- 调用生成的 SOAP 操作、白名单表的查询/插入与命名查询,或白名单 REST 端点
- 每次调用先按 JSON Schema 校验再发往后端,并写入本地审计日志
- 打开本地测试聊天页,为每个发现的工具给出示例问题,并打印客户端连接片段
- 适用场景
- 当助手需要安全、带类型地访问遗留系统(SOAP 服务、老旧数据库或缺少文档的 REST API),又不想手写适配代码时使用。也适合在 CI 中固定 WSDL 契约,或先加一层 MCP 以便日后替换后端。
- 运行要求
- 本地安装 Python 包(pip、pipx 或 uvx)并准备描述适配器的 config.yaml。后端凭据以环境变量名引用(password_env、dsn_env、token_env),运行时读取。源码扫描的可选 LLM 辅助步骤需通过 --llm-api-key-env 提供兼容 OpenAI 的 API 密钥。需能访问 WSDL、REST 基址或被爬取的站点。仅支持 stdio 传输。
安装
在 SourceWeft 中
- 打开 控制台中的 legacy2mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
legacy2mcp
[CI] [PyPI] [Python versions] [MCP Registry] [Glama score] [License]
[Stars] [Forks] [Contributors] [Last commit] [PyPI downloads]
[Verified: Claude Desktop] [Verified: Cursor] [Verified: VS Code] [Claude Code] [Tested with MCP Inspector]
Convert anything to MCP in 60 seconds. Read-only by default, with every call audit-logged.
Quick start
No API key, no cloning — pick whichever matches what you actually have, against live public demo targets:
Run any one of those from a real terminal and that's the whole thing: it
writes config.yaml, opens a local test-chat page with a clickable example
question under every discovered tool — click one and see a real response
come back from the live source, no AI key needed, just local keyword
matching to sanity-check the server works — and prints a ready-to-paste
connection snippet for Claude Desktop, Cursor, VS Code, and Claude Code.
Wiring it into a real AI client is a copy-paste, not a separate step.
(Prefer the raw tool list instead? legacy2mcp inspect --config config.yaml.)
legacy2mcp discover
does the same for sources that benefit from a review step first (a
Postman collection, a HAR capture, …): write a contract, open the same
test chat, print the same connection snippet — one command either way.
Have your own WSDL, REST API, website, or codebase instead? legacy2mcp init (no flags) walks you through it — see
Generate a config automatically. More
demos (a local SOAP service, Docker, a WSDL served by raw URL) are listed in
examples/.
[!NOTE]
legacy2mcpintrospects your legacy system live — every WSDL operation, every database table, every REST spec it can find — and builds a real JSON Schema for each tool from it. Every MCP tool call is schema-validated before it reaches your backend, write operations are excluded by default, and every call is audit-logged. No hand-written adapter code, no hand-maintained schemas, no arbitrary SQL from the LLM.
Contents
- Install
- Quick start
- How it works
- Why not just write an adapter by hand?
- Point it at your own WSDL
- Point it at your own database
- Point it at your own REST API
- Generate a config automatically
- Discover a legacy interface before generating a server
- Teach your AI coding agent about legacy2mcp
- Common commands
- Client support
- What's handled
- Safety model
- Data flow and privacy
- Use cases
- Real-world usage
- Configuration reference
- Documentation
- Roadmap
- Development · Contributing · License
Install
Also published to the MCP Registry as io.github.bvenkata/legacy2mcp, so registry-aware MCP clients can discover it directly.
How it works
SOAP:
- Loads the WSDL with
zeep, a mature, widely-used Python SOAP client. - For every operation on every port/binding, converts the XSD input type into a JSON Schema (
schema/xsd_to_jsonschema.py) — simple types, nested complex types, enums and arrays, recursively, depth-limited for pathological WSDLs. - Registers one MCP tool per operation, named
<adapter_id>_<OperationName>. - On a tool call: validates arguments with
jsonschema(schemas useadditionalProperties: false), calls the operation viazeep, serializes the response to plain JSON, and writes an audit entry.
DB:
- Connects with the dialect's driver (
psycopg/pyodbc/oracledb, imported lazily) and introspects the live column types for each allowlisted table (adapters/db_dialects.py) into JSON Schema (schema/sql_to_jsonschema.py). - Registers
select_<table>/insert_<table>per allowlisted table-and-operation, plusquery_<name>per named query in config. - On a tool call: validates arguments, builds SQL from the allowlisted table/columns (or runs the config-supplied named query) using one dialect-neutral
:paramplaceholder convention, executes it, and writes an audit entry. The LLM never sees or writes SQL text. - Operations whose names look like writes are excluded unless
allow_write_operations: true.
REST:
- There's no live schema to introspect a plain REST API from the way there is a WSDL or a DB catalog, so the endpoint list (method, path, typed params) comes from config -- hand-written, or generated by
legacy2mcp init's OpenAPI/Swagger discovery or source-code scan. - Registers one MCP tool per allowlisted endpoint, named
<adapter_id>_<name>. - On a tool call: validates arguments, splits them into path/query/body by each param's declared
location, substitutes{param}placeholders into the URL, and calls it withrequests-- auth applied per the adapter'sauthconfig (basic/bearer/none). - Endpoints marked
write: trueare excluded unlessallow_write_operations: true.legacy2mcp initsets that flag by default on non-GETendpoints and on endpoints whose names look like writes; in a hand-written config, the HTTP method alone does not hide an endpoint.
Why not just write an adapter by hand?
Because a hand-written adapter is a second copy of your system's schema that nobody remembers to update. The first time a WSDL operation's signature shifts or a column changes, your tool's JSON Schema silently drifts from reality — and an LLM calling it finds out by sending arguments that are wrong in a way nothing catches, or by getting a confusing runtime error from deep inside the SOAP/DB client. legacy2mcp builds the schema from the live system every time it starts, so a drifted call fails at validation, before it ever reaches your backend — not after.
Point it at your own WSDL
A production-shaped template with comments lives at examples/soap/config.template.yaml.
Point it at your own database
Columns are introspected from the live schema at startup, the same way SOAP operation
schemas come from the WSDL -- there's nothing to hand-maintain. There is no path from
the LLM to arbitrary SQL, ever: it can only call select_<table> / insert_<table> for
tables listed under tables:, or a query_<name> tool whose SQL you wrote under
queries: -- the LLM supplies only the placeholder values a query's params declare,
never SQL text. A production-shaped template lives at
examples/db/config.template.yaml.
Point it at your own REST API
There's no WSDL or live database schema to introspect a plain REST/JSON API
from, so the rest adapter's endpoint list is explicit config -- write it
by hand, or generate a starting point with legacy2mcp init (next
section).
A production-shaped template lives at
examples/rest/config.template.yaml.
[!NOTE] Both a non-
GETmethod and an LLM-assisted classification are heuristics, not a guarantee the endpoint is actually safe to call unsupervised -- reviewwrite:flags andallow_write_operationsbefore running against a real backend, same caveat as the SOAP adapter's write-verb heuristic below.
Generate a config automatically
legacy2mcp init asks what to point it at, then writes a starting
config.yaml for you:
Each also works non-interactively via a flag -- --wsdl-url, --rest-url,
--webpage-url, --github-url, or --local-path -- for scripting or CI.
Only the GitHub/source-code path can use an LLM, and only to refine what
static analysis already found (ambiguous parameter types, read-vs-write
classification) -- never a dump of your repo. It needs no extra
dependency, just an OpenAI-compatible API key via --llm-api-key-env, or
an interactive hidden prompt if you omit that (never written to disk);
pass --scan-only to skip it outright and run static-analysis-only, same
as not entering a key.
Whichever path you take, review the generated file before running it --
it's marked up with # TODO comments for anything that couldn't be
confidently inferred (an unresolved base_url, an unverified param type,
which endpoints got classified write: true), and nothing in it is
verified against the real backend until you do:
legacy2mcp init also writes a plain-English HTML report next to the
config (e.g. config.yaml -> config.html) -- open it in a browser to see,
in sentences rather than YAML, what tools the server will expose (every
REST endpoint / DB table / SOAP target it found, which ones can change data
and are gated behind allow_write_operations, and the review items above).
Pass --html-out to change where it's written, or --no-html-report to
skip it.
Run init from a real terminal against a config that's already usable
(a live --wsdl-url/--rest-url, or a scan that found something concrete)
and it also opens a local test-chat page in your browser, with a
clickable example question under every discovered tool (generated from
that tool's own name and schema, e.g. getPetById -> "get pet by id 4") so
you don't have to guess what to type. Click one, or type your own, and it
matches it to a discovered tool, calls the real adapter, and shows you the
real response. No AI/API key needed for this -- it's local keyword
matching against the tool names/descriptions, not an LLM, just enough to
sanity-check that the server actually works before you wire up a real MCP
client. It's skipped automatically when the config still has TODOs to fill
in (nothing to connect to yet), and never opens at all in
non-interactive/scripted runs. Pass --no-chat to opt out.
See docs/security.md for exactly what this heuristic does and doesn't guarantee before pointing it at anything real.
Discover a legacy interface before generating a server
init covers a live WSDL, a live REST URL, a website (--webpage-url),
and a repo it can scan -- all of those go straight to a config, no
separate step needed. For everything else -- a Postman collection someone
already built, an OpenAPI spec file sitting in a repo with no server
running yet, a database's stored-procedure catalog, a HAR capture of real
traffic, or queues you already know about -- there's an explicit step
first:
A website can go through discover --webpage-url too (see below) if you
want to review the contract before anything gets built -- init --webpage-url runs the identical crawl, it just doesn't pause there.
Each writes a Legacy Interface Contract (contract.yaml): every
operation's inputs, outputs, enums, error codes, whether it reads or
writes, and a confidence level -- high for a live schema/catalog,
medium for a curated artifact like a Postman collection, low for
anything inferred from sampled traffic -- plus needs_review flags and
notes on anything uncertain. Review it like you'd review config.yaml's
# TODOs.
Run that same command from a real terminal, though, and discover doesn't
stop at the contract: if the contract has anything invocable in it (not
every source does yet -- see below), it also writes a runnable
config.yaml, opens the same no-API-key test-chat page init can
auto-launch, and prints the same ready-to-paste MCP client JSON --
discover, try it, and get the connection snippet, in the one command you
already ran. Pass --no-chat to skip that and just get the contract (the
default in non-interactive/CI runs already), or --no-write-config to skip
only the config.yaml write.
Prefer to review the contract first before anything gets built or run? Skip straight to either step yourself instead:
demo is the same "try it" step discover can auto-launch, just callable
on its own (also works from an existing --config config.yaml, not only a
contract) -- it saves a standalone chat.html pointing at the server it
just started (opened automatically unless --no-open), and prints the
client JSON once a config exists to point it at. The command has to keep
running (Ctrl+C to stop) for that page to work; it's a thin client page
with no backend of its own, so the real HTTP calls still have to be made by
something, same reason the browser can't just open a config file and
call a REST API directly.
A few things worth knowing:
- No raw secret is ever written into a contract. A Postman collection's
saved bearer token, a HAR capture's
Authorization/Cookieheader values -- none of it gets persisted; only a note that auth was present, for you to configure yourself. The one controlled exception is a small, non-sensitive-looking enum (e.g. astatusfield that only ever took a handful of values across enough samples to mean something) -- see docs/security.md. - For
--har-file, legacy2mcp never drives a capture proxy itself -- point it at a HAR produced by anything: your browser devtools' "Export HAR", Postman's own traffic capture, or mitmproxy's built-in exporter (mitmdump --set hardump=out.har, or "Export as HAR" in the GUI). This is the lowest-confidence source (inferred from whatever was sampled, not a declared contract) -- every operation comes back flagged for review. --webpage-urlis for a legacy web app or content site with no API docs at all -- just a URL. It crawls same-site pages from there (--max-pages/--max-depthbound it, default 25 pages / depth 2, never leaving the starting host), turning every<form>into an operation (a<select>'s options, or a shared-name radio/checkbox group, become anenum) and every form-less page with real content into a read-only "get this page" tool. No JavaScript is executed and nothing is ever submitted; non-GET forms get a note to confirm the backend accepts a JSON body (the REST adapter always sends one, even though a real browser would POSTapplication/x-www-form-urlencoded). Same lowest-confidence posture as--har-file-- but unlike every otherdiscoversource,base_urlfills in automatically (it's the host just fetched), so the test-chat page opens right away. Full crawl mechanics: docs/security.md.- Stored procedures and queue descriptions are documented, not runnable
yet.
--stored-procsand--queue-configstill produce real contract entries -- there's no adapter to actually call either today (see docs/roadmap.md), soinit --from-contractskips them with a clear TODO rather than pretending they work. Same reasondiscover's auto-demo (above) has nothing to launch for a contract made up only of those -- it says so and just exits with the contract already written, rather than failing the whole command. - Every generated server also gets a
describe_capabilitiestool for free -- a connected agent can call it to ask "what can this system do?" (every tool's description, side effect, confidence, required fields, known error codes) before calling anything for real. --out contract.htmlwrites a human-readable report instead of the plain YAML -- the same operations, as a table, in your browser. It's still a valid--from-contract/demo --from-contractinput: the full contract is embedded in the page (in a<script type="application/json">tag), not just summarized for reading.
Teach your AI coding agent about legacy2mcp
The sections above are about the MCP servers legacy2mcp produces. This
one is different: it's for when an AI coding agent (Claude Code, Cursor,
Codex CLI, Gemini CLI, GitHub Copilot, ...) is helping you build the
integration in the first place, and you want it to already know how.
This writes short, command-first legacy2mcp instructions directly into the
current repo's own agent context files — a Claude Code slash command
(.claude/commands/legacy2mcp.md), a Cursor rule
(.cursor/rules/legacy2mcp.mdc), and a ## legacy2mcp section appended (or
updated in place) in AGENTS.md, GEMINI.md, and
.github/copilot-instructions.md. The agent then already knows the core
workflow — which init flag fits which source, review the # TODOs before
trusting a generated config, check inspect before running anything live —
without you re-explaining it every session. It's idempotent: re-running it
replaces its own section rather than duplicating it, so it's safe to run
again after an upgrade. Review what it writes and commit it so your whole
team gets the same instructions (this repo does exactly that — see
AGENTS.md).
There's also a standalone SKILL.md in this repo,
written to the open Agent Skills standard
— the same know-how in a form marketplaces like Agensi
can list independently of any particular repo, for agents that discover
skills that way instead.
Common commands
Client support
[Verified: Claude Desktop] [Verified: Cursor] [Verified: VS Code] [Claude Code] [Tested with MCP Inspector] [MCP compatibility]
"Verified" here means a specific, narrow thing: the exact command + config
shape shown below was actually spawned and completed a real MCP
initialize handshake over stdio -- not just "MCP should be compatible."
For MCP Inspector, the loop was driven further: a real tools/list, a real
tools/call, and the resulting audit log entry, all
headlessly via the Inspector's own --cli mode. The last badge is what
keeps that claim honest over time rather than a one-time snapshot: a CI job
(mcp-compatibility.yml) re-runs
that same tools/list / tools/call / audit-log loop on every push and
fails the build if the server can't start or exposes the wrong tools. Every
client below talks to legacy2mcp over stdio only -- there's no
HTTP/SSE transport yet (it's on the roadmap, not
shipped), so an http://localhost:... MCP URL won't work here.
This repo also ships the checked-in configs themselves --
.mcp.json, .cursor/mcp.json, and
.vscode/mcp.json -- pointed at the bundled Petstore
demo, so opening this repo in one of these tools gets you a working server
with no setup. Copy whichever matches your tool into your own project and
point --config at your own config.yaml.
Claude Desktop — claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
If you installed with pip/pipx instead of uv, use "command": "legacy2mcp" and drop the
first element of args.
Cursor — .cursor/mcp.json
Project-local (.cursor/mcp.json) or global (~/.cursor/mcp.json):
VS Code — .vscode/mcp.json
Claude Code — CLI
Add --scope project to write a shared .mcp.json for your team (keep secrets out of it);
check with claude mcp list.
MCP Inspector — a validation tool, not an AI client
Opens a local web UI: connect to the server, confirm tools are listed, run one read-only tool,
and check legacy2mcp-audit.log for the matching entry. That exact loop -- tool discovery, one
real call, the audit log it produces -- is what the "Tested with MCP Inspector" badge above
is actually backed by, driven headlessly through the Inspector's own --cli mode rather than
just opened in a browser.
Passing secrets and troubleshooting: docs/clients.md.
What's handled
See docs/security.md for the full, honest security model — what's covered today and what isn't yet.
Safety model
[!WARNING] The SOAP write-operation filter is a name heuristic, not semantic analysis — an operation called
ProcessRecordthat deletes data would not be caught. For any system where a wrong call has real consequences, setinclude_operationsexplicitly and don't rely on the heuristic. The DB adapter's allowlist is explicit by construction, but there's no column-level data masking — an allowlisted column's values are always returned as-is. There is also no auth/authz on the MCP server itself yet — don't expose a server to untrusted callers. Details in docs/security.md.
Data flow and privacy
- No telemetry. legacy2mcp collects no usage data and phones home to nothing. Every network call it makes is one you configured it to make — verified by checking every outbound HTTP call site in the source before writing this sentence.
- Adapter calls go exactly where you pointed them, nowhere else. SOAP calls go to your
wsdl_url, DB calls go to yourdsn_envconnection, REST calls go to yourbase_url. legacy2mcp init's discovery calls are scoped to what you gave it. The WSDL path only contacts the URL you passed. The REST path probes the usual OpenAPI/Swagger locations under that URL.--webpage-urlcrawls same-site pages from the URL you passed, bounded by--max-pagesand--max-depth. Both follow HTTP redirects, so a server that redirects can send a request to another host. The GitHub/source-code path clones the repo you specify and parses it locally withast— nothing from it is ever executed.- The optional LLM-assist step sends only already-detected, ambiguous fragments — never your repo. It only runs on the GitHub/source-code path of
legacy2mcp init, only if you provide an API key, and only sends the specific route names/paths/params the static scan already flagged as ambiguous, not a dump of your source. Skip it entirely with--scan-only. legacy2mcp discoverreads local files, except--stored-procsand--webpage-url. Postman, OpenAPI, HAR, and queue sources never touch the network — they read a file you passed.--stored-procsconnects to the DSN in the env var you named, the same way thedbadapter does, only to read the procedure/function catalog.--webpage-urlfetches the URL you passed and same-site pages linked from it, following HTTP redirects. No raw secret or sampled value is ever written into the resultingcontract.yaml— see docs/security.md.- Secrets never live in
config.yaml. Passwords, DSNs, and API tokens are all referenced by environment-variable name (password_env,dsn_env,token_env) and read at runtime — the YAML stays safe to commit. - The audit log stays local and is not encrypted at rest. Every tool call is appended as one JSON line to
security.audit.path. Arguments are logged as-is — there's no PII redaction; see docs/security.md for the full list of what the audit log does and doesn't do.
Use cases
Real-world usage
In CI/CD — catch WSDL drift before it reaches production
legacy2mcp inspect loads the config, contacts the WSDL, builds every schema, and exits non-zero if anything fails:
Exit codes:
As a sidecar / long-running MCP server
legacy2mcp run speaks MCP over stdio. Package it with your config using the provided Dockerfile and let your MCP client launch it.
In a data pipeline
Call the same generated, validated tools from your own code via any MCP client library to pull records on a schedule — the audit log records exactly what was fetched.
Configuration reference
SOAP adapter config:
DB adapter config:
REST adapter config:
Security config:
Documentation
Roadmap
Full detail in docs/roadmap.md. The BaseAdapter interface (discover_tools() + invoke()) is the extension point — the server core handles validation, dispatch and audit for any adapter.
Development
Tests run against an in-process mock SOAP service and an in-process SQLite-backed
stand-in for the DB adapter — no network, no real Postgres/SQL Server/Oracle
required. The DB adapter's Postgres/SQL Server/Oracle dialects (db_dialects.py)
have their SQL-translation logic covered by driver-free unit tests; connecting to
a real instance of each is not part of the default suite.
CI runs the suite on Python 3.10–3.12 (ci.yml). Releases to PyPI and the MCP Registry are tag-triggered — see docs/releasing.md. The demo GIF is regenerated with vhs demo/demo.tape (demo/).
Contributing
Adapters for new legacy systems are the highest-value contribution — implement BaseAdapter and the core handles the rest. See CONTRIBUTING.md for dev setup, how adapters are structured, and PR expectations. This project follows the Code of Conduct. Issues and PRs welcome.
License
来源:README.md,提交 817384b
工具
0版本历史
8- v0.5.1最新Oct 23, 2026
- v0.4.0Oct 22, 2026
- v0.2.6Oct 15, 2026
- v0.2.5Oct 14, 2026
- v0.2.3Oct 14, 2026
- v0.2.2Oct 13, 2026
- v0.2.1Oct 11, 2026
- v0.1.0Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分