Support a configured Accept header in the REST adapter
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
Support a configured Accept header in the REST adapter. Problem The REST adapter currently sends authentication headers but has no way to declare an Accept media type. FHIR servers commonly use application/fhir+json, so the guide in PR 173 has to expose a required _format=json query argument on every endpoint to fo
Why It Matters
Resolving #176 improves reliability and developer experience in OWASP/legacy2mcp.
Expected Outcome
A focused pull request addressing #176 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, SQL & Databases, Git & Collaboration, AppSec & Validation, 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
Branching, commits, rebasing, and collaborative Git workflows.
Addresses skill gap: Git & Collaboration
Relational modeling, joins, constraints, and query optimization.
Addresses skill gap: SQL & Databases
Core Python syntax, functions, control flow, and debugging basics.
Addresses skill gap: Python
Issue Description
Problem
The REST adapter currently sends authentication headers but has no way to declare an Accept media type. FHIR servers commonly use application/fhir+json, so the guide in PR #173 has to expose a required _format=json query argument on every endpoint to force JSON.
This is awkward for callers, duplicates transport configuration in tool schemas, and can expose an implementation detail that should be fixed by the adapter configuration.
Proposed change
Add a reviewed way for a REST adapter, or an individual endpoint, to send a configured Accept header. For example:
config:
base_url: https://fhir.example.com/r4
accept: application/fhir+json
The final configuration shape can follow existing REST settings conventions. It should not provide a way for tool callers to choose or override headers at runtime.
Acceptance criteria
- A configured media type is sent as the
Acceptheader on REST requests. - Bearer and basic authentication continue to work unchanged.
- Tool arguments cannot add, replace, or remove request headers.
- Invalid or empty configured media types fail config validation.
- Existing configurations without the setting keep their current behavior.
- Offline tests assert the received header against the in process mock REST service.
- The FHIR guide can remove the required
_format=jsonworkaround after the feature ships.
Security notes
Header values come from reviewed configuration, not MCP tool arguments. Secrets must continue to use the existing environment variable based authentication settings and must not be copied into a generic headers mapping.
Context
Found while testing HAPI FHIR R4 for #141. The current workaround and PHI considerations are documented in PR #173. FHIR CapabilityStatement discovery is tracked separately 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. A single reviewed accept: setting (not a general headers map) is the right shape, and your security notes are exactly the ones that matter. Implementation notes:
- Add
accept: str | None = NonetoRestAdapterSettingsinconfig.py, and merge it intoRestAdapter._headers(), which today only addsAuthorization. - Validate it as a media type, such as
^[\w.+-]+/[\w.+-]+(\s*;\s*[\w.+-]+=[\w.+-]+)*$. That rejects empty values and, importantly, CR/LF, so a config value can't inject a second header. - A per-endpoint override can wait until someone needs it. Adapter-level covers FHIR.
tests/mock_rest_service.pycan echo the receivedAcceptheader for the assertion.
Labelling this good first issue too.
I'd like to take this adapter-level accept setting, following @bvenkata's scope above. I will keep it out of tool arguments, validate a single media type without CR/LF, and test received headers on the local REST fixture with no-auth, bearer and basic auth controls, plus unchanged defaults and rejected runtime header overrides. I'll update the REST configuration docs and FHIR guide in the same PR. No per-endpoint override or generic headers map. Working with Codex assistance; no live FHIR/patient-data calls are planned.
Implemented in https://github.com/OWASP/legacy2mcp/pull/181. Actual local validation: 32 REST tests; full630passed3optional-skips; rootRuff/diff and3FHIRYAMLconfigs validate. 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.