mcp: support http(s) URLs for spec_path in OpenAPI MCP loader - #20753
Conversation
…-delta-index-mapping fix(responses): preserve tool call argument deltas when streaming id is omitted
add missing indexes on VerificationToken table
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Andrea Odorisio seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Greptile OverviewGreptile SummaryThis PR aligns the MCP OpenAPI loader’s documented Main integration concern: URL loading currently uses Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/proxy/_experimental/mcp_server/openapi_to_mcp_generator.py | Adds URL support to load_openapi_spec() via direct httpx.get; main concern is it bypasses the project’s custom httpx client/config used elsewhere in this module. |
| tests/mcp_tests/test_openapi_spec_path_url.py | Adds a unit test that monkeypatches httpx.get to validate load_openapi_spec() can load an OpenAPI spec from an http URL. |
Sequence Diagram
sequenceDiagram
participant Caller as MCP OpenAPI Loader
participant Loader as openapi_to_mcp_generator.load_openapi_spec
participant URLParse as urllib.parse.urlparse
participant FS as Local filesystem
participant Httpx as httpx.get
Caller->>Loader: load_openapi_spec(spec_path)
Loader->>URLParse: urlparse(spec_path)
alt spec_path scheme is http/https
Loader->>Httpx: GET spec_path (timeout=30s)
Httpx-->>Loader: Response (json)
Loader-->>Caller: dict spec
else local path
Loader->>FS: open(spec_path)
FS-->>Loader: file contents
Loader-->>Caller: json.load(file)
end
Caller->>Caller: get_base_url(spec)
Caller->>Caller: register_tools_from_openapi(spec, base_url)
| def load_openapi_spec(filepath: str) -> Dict[str, Any]: | ||
| """Load OpenAPI specification from JSON file.""" | ||
| with open(filepath, "r") as f: | ||
| """Load OpenAPI specification from JSON file or URL.""" | ||
| parsed = urlparse(filepath) | ||
| if parsed.scheme in ("http", "https"): | ||
| # fetch spec from URL | ||
| r = httpx.get(filepath, timeout=30.0) | ||
| r.raise_for_status() | ||
| return r.json() |
There was a problem hiding this comment.
Bypasses configured HTTP client
load_openapi_spec() now fetches URL specs via httpx.get(...) directly, but the rest of this module uses get_async_httpx_client(..., llm_provider=httpxSpecialProvider.MCP) to ensure the project’s custom httpx configuration (proxies, TLS settings, auth headers, instrumentation, etc.) is applied. As-is, loading specs from URLs will ignore those settings and can fail in deployments that require them. Prefer using the same shared/custom httpx client path for URL loads as well.
Ensure URL-based OpenAPI loading honors LiteLLM’s custom httpx configuration, add missing imports, and harden tests to prevent regressions or accidental direct httpx usage.
26893ab
into
BerriAI:litellm_oss_staging_02_09_2026
* fix(responses): preserve streamed tool deltas when id is omitted * fix(responses): guard ambiguous tool-call index reuse * add missing indexes on VerificationToken table * mcp: support http(s) URLs for spec_path in OpenAPI MCP loader * test(mcp): add unit test for OpenAPI spec_path URL support * Fix OpenAPI spec URL loading to use shared MCP httpx client Ensure URL-based OpenAPI loading honors LiteLLM’s custom httpx configuration, add missing imports, and harden tests to prevent regressions or accidental direct httpx usage. * removed unused import urlparse * removed unsupported timeout argument --------- Co-authored-by: Emerson Gomes <emerson.gomes@thalesgroup.com> Co-authored-by: Sameer Kankute <sameer@berri.ai> Co-authored-by: Carlo Alberto Ferraris <cafxx@mercari.com> Co-authored-by: Andrea Odorisio <Andrea@BR-FHH9MWDQ2PMAC.local>
…I#20753) * fix(responses): preserve streamed tool deltas when id is omitted * fix(responses): guard ambiguous tool-call index reuse * add missing indexes on VerificationToken table * mcp: support http(s) URLs for spec_path in OpenAPI MCP loader * test(mcp): add unit test for OpenAPI spec_path URL support * Fix OpenAPI spec URL loading to use shared MCP httpx client Ensure URL-based OpenAPI loading honors LiteLLM’s custom httpx configuration, add missing imports, and harden tests to prevent regressions or accidental direct httpx usage. * removed unused import urlparse * removed unsupported timeout argument --------- Co-authored-by: Emerson Gomes <emerson.gomes@thalesgroup.com> Co-authored-by: Sameer Kankute <sameer@berri.ai> Co-authored-by: Carlo Alberto Ferraris <cafxx@mercari.com> Co-authored-by: Andrea Odorisio <Andrea@BR-FHH9MWDQ2PMAC.local>
Relevant issues
Fixes documentation/implementation mismatch where
spec_pathis documented as supporting URLs, but the loader only supported local filesystem paths.Type
🐛 Bug Fix
Changes
spec_pathhandling in MCP OpenAPI loader to support both:http(s)URLsspec_path: path or URL)Pre-submission checklist
tests/mcp_tests/Test results
Ran MCP unit tests successfully (excluding two tests that are unrelated to this change and currently fail due to import/runtime environment requirements):
Result: 89 passed, 5 skipped