Probe /api-docs and /v3/api-docs during REST discovery
Opened by @Mahnoor-Zaffar · Assignees: None
Solve & Merge Reward: Up to +210 XP & +60 Coins
+30 XP on PR open · +180 XP & +60 coins on merge
Claim Status & GitHub Signal
Unassigned, with 2 comments. Unassigned does not guarantee unclaimed—read comments and linked PRs first.
Estimated from issue labels (enhancement, good first issue), Python context, and discussion depth. There are 2 GitHub comments to review for maintainer clarifications. Note: this is an estimate, not a guarantee.
What It's About
Probe /api-docs and /v3/api-docs during REST discovery. Problem legacy2mcp init --rest-url probes only these conventional OpenAPI paths: /openapi.json /swagger.json /v1/openapi.json /api/openapi.json During 141 and PR 173, the HAPI FHIR R4 server returned 404 for all four paths but served OpenAPI 3.0.1 from /api-do
Why It Matters
Resolving #175 improves reliability and developer experience in OWASP/legacy2mcp.
Expected Outcome
A focused pull request addressing #175 with relevant checks or tests verified locally.
Log in to compare this issue's requirements against your profile skills. Required concepts: Python, HTTP & REST APIs, Machine Learning.
Progressive AI Hints
Hint #1 is always free and calibrated to your experience level. Extra hints unlock with coins without spoiling the full solution.
Skill-Gap Learning
Issue Description
Problem
legacy2mcp init --rest-url probes only these conventional OpenAPI paths:
/openapi.json/swagger.json/v1/openapi.json/api/openapi.json
During #141 and PR #173, the HAPI FHIR R4 server returned 404 for all four paths but served OpenAPI 3.0.1 from /api-docs. Springdoc commonly serves its document from /v3/api-docs.
HAPI's document is YAML rather than JSON, so adding the candidate path alone is not sufficient. The live document was about 7.5 MB and produced 4,611 operations through discover --openapi-file.
Proposed change
- Add
/api-docsand/v3/api-docsto live REST discovery. - Parse a successful candidate as JSON or YAML based on its content, using the same validation boundary as
load_spec_from_file. - Accept a document only when it is a mapping with a top level
pathsfield. - Keep probing bounded to the configured base URL and the explicit candidate list.
- Include every attempted path in the final discovery error.
Acceptance criteria
- A HAPI style YAML response at
/api-docsis discovered. - A springdoc style JSON response at
/v3/api-docsis discovered. - Invalid YAML, invalid JSON, HTML, and documents without
pathsare ignored safely. - Existing OpenAPI candidate paths continue to work.
- Tests use local mocked responses and require no network.
- Documentation warns users to review and reduce very large generated endpoint lists.
Context
This was found while testing HAPI FHIR for #141. The verified workaround and operation counts are documented in PR #173. CapabilityStatement based discovery remains separate in #174.
Linked Pull Requests (0)
No linked or cross-referenced pull requests detected via GitHub timeline. Check comments below for informal claims before starting.
GitHub Comments (2)
Thanks @Mahnoor-Zaffar, clear and well-bounded. Two implementation notes:
load_spec_from_fileindiscovery/openapi.pyalready parses JSON and YAML withyaml.safe_load. Factor that into a shared_parse_spec(text)that both the file and URL paths call, so the "a mapping withpaths" check exists in one place.- Size: HAPI's spec is about 7.5 MB, and parsing YAML that size takes a few seconds. Please cap the download (stream it and stop past, say, 25 MB, with a clear error). Also have
initprint a warning when a spec yields more than a couple of hundred operations, pointing at the review step. Thousands of tools aren't usable by an MCP client.
Labelling this good first issue, since it's self-contained and the tests can all use mocked responses.
I'd like to take #175 as a separate discovery change, following the shared parser, streamed download limit and large-catalog warning requested above. I'll test both new paths, existing candidates, JSON/YAML parity, invalid responses, response closure and byte-limit enforcement with local mocked streams; no live HAPI call is needed. I'll keep this independent of the Accept-header change in #181. Working with Codex assistance.
Implemented in https://github.com/OWASP/legacy2mcp/pull/183. Actual local validation: 47 focused tests; full626passed3optional-skips; rootRuff/diff andrealHTTPgzipstreamingprobe pass. Open for review, not yet merged; no live HAPI/patient-data/model calls. See the PR for the exact limits and checks.
Issue Troubleshooting Threads (0)
No troubleshooting threads opened for this issue yet. If you hit a test, build, or navigation blocker, post what you've tried so fellow contributors can help.
PR Verification & Rewards
Sign in and link GitHub to verify your PR against this issue and earn XP + coins.
Contribution Workflow
Track your local progress before opening a pull request on GitHub.
Repository Context
Top Repository Paths
CONTRIBUTING.md Excerpt
Contributing
New here? Start with an issue labeled
good first issue
-- small, self-contained, scoped to one file or one function. Looking for
something bigger? help wanted
issues are real gaps that need more design/discussion, not busywork. Either
way, comment on the issue before starting so two people don't duplicate
work, and feel free to ask questions on it -- that's what it's there for.
What's next (short version)
The authoritative, up-to-date list is always the open
good first issue/
help wanted
issues, not this file -- but in short, the biggest gaps today are:
- More queue brokers (
type: queue) -- the adapter publishes to and peeks at RabbitMQ queues; Kafka, SQS and consuming for real are still future work. - Stored-procedure calling --
discover --stored-procsalready reads a live procedure/function catalog, and thedbadapter can call a Postgres one listed underprocedures:; SQL Server and Oracle calling, and converting a--stored-procscontract ininit --from-contract, are still future work. - A direct
init --db-dialect ... --db-dsn-env ...entry point -- today adbconfig only comes from a repo scan (ORM detection) or a hand-written config; there's no live "point at a database and get a starter config" path the way--wsdl-url/--rest-url/--webpage-urlalready have. - HTTP/SSE transport --
stdioonly today. - More
analyzecoverage -- new frameworks (Koa, Hapi, NestJS, Starlette, Litestar), new side-effect rules (more payment, email and queue SDKs), and the first analyzer for another language. These are the best first contributions: docs/good-first-issues.md has a list of small, well-scoped ones with exact file pointers.
Full version-by-version history: docs/roadmap.md.
Development setup
git clone https://github.com/OWASP/legacy2mcp.git
cd legacy2mcp
pip install -e ".[dev]"
pytest tests/ -v
[dev] pulls in pytest, pytest-asyncio, flask, lxml, pathspec,
the tree-sitter grammars and the anthropic SDK -- enough to run the full
suite with
... (truncated)
Advisory PR Assistant
Helps structure your PR description or unpack reviewer feedback. Does not perform GitHub actions.