DevWeave logoDevWeave
CommunitiesDiscoverHelp ForumFeaturesWhy DevWeaveAI & Verification
Log inGet started
Back to Issue Discovery
OWASP/legacy2mcp #175openPythonCybersecurity

Probe /api-docs and /v3/api-docs during REST discovery

Opened by @Mahnoor-Zaffar · Assignees: None

View on GitHub
enhancementgood first issue

Solve & Merge Reward: Up to +210 XP & +60 Coins

+30 XP on PR open · +180 XP & +60 coins on merge

17 GitHub Stars

Claim Status & GitHub Signal

Unassigned, with 2 comments. Unassigned does not guarantee unclaimed—read comments and linked PRs first.

AI Issue Assessment · Grounded Analyzer
2.8 / 10 · 3–4 · Beginner

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.

Skill Match Breakdown

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.

Log in to receive your free level-adapted Hint #1 grounded in this repository's files.

Skill-Gap Learning

Gap-Targeted
Learn Code in Python

Core Python syntax, functions, control flow, and debugging basics.

Addresses skill gap: Python

Hands-On CodeCrafters Practice
Skill-Gap Challenge
Build your own HTTP Server
Python

Handle raw TCP connections, HTTP parsing, headers, and concurrent routes.

Practice skill gap: Python

Build your own Redis
Python

Create a TCP event loop, RESP protocol parser, and TTL key-value cache.

Practice skill gap: Python

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-docs and /v3/api-docs to 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 paths field.
  • 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-docs is discovered.
  • A springdoc style JSON response at /v3/api-docs is discovered.
  • Invalid YAML, invalid JSON, HTML, and documents without paths are 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)

@bvenkataCOLLABORATOR
View comment →

Thanks @Mahnoor-Zaffar, clear and well-bounded. Two implementation notes:

  • load_spec_from_file in discovery/openapi.py already parses JSON and YAML with yaml.safe_load. Factor that into a shared _parse_spec(text) that both the file and URL paths call, so the "a mapping with paths" 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 init print 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.

@austinchennn
View comment →

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.

Peer Help Forum · OWASP/legacy2mcp #175

Issue Troubleshooting Threads (0)

Ask Peers for Help

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.

Sign In

Contribution Workflow

Track your local progress before opening a pull request on GitHub.

Repository Context

Top Repository Paths

[dir] .claude
[dir] .claude/commands
.claude/commands/legacy2mcp.md
[dir] .cursor
.cursor/mcp.json
[dir] .cursor/rules
.cursor/rules/legacy2mcp.mdc
[dir] .github
[dir] .github/ISSUE_TEMPLATE
.github/ISSUE_TEMPLATE/config.yml
.github/ISSUE_TEMPLATE/new-analyzer.yml
.github/ISSUE_TEMPLATE/new-legacy-technology.yml
.github/copilot-instructions.md
.github/dependabot.yml
[dir] .github/workflows
.github/workflows/ci.yml
.github/workflows/mcp-compatibility.yml
.github/workflows/release.yml
.gitignore
.mcp.json
[dir] .vscode
.vscode/mcp.json
AGENTS.md
AUTHORS

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-procs already reads a live procedure/function catalog, and the db adapter can call a Postgres one listed under procedures:; SQL Server and Oracle calling, and converting a --stored-procs contract in init --from-contract, are still future work.
  • A direct init --db-dialect ... --db-dsn-env ... entry point -- today a db config 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-url already have.
  • HTTP/SSE transport -- stdio only today.
  • More analyze coverage -- 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.