Commit Graph

380 Commits

Author SHA1 Message Date
Pietro Zullo 3350560957 chore(python): release 1.7.1 (#2509) 2026-09-10 17:51:20 +02:00
AxelRay 40ee6c3a26 docs(python): fix misleading CI badges (#1871) (#1872) 2026-08-26 15:47:50 -07:00
Enrico Toniato 173b2d54a2 fix: make canary conformance release evidence explicit (#2205) 2026-08-09 12:58:06 +02:00
Enrico afe3f11200 fix(ci): format Python README and repair docs link 2026-07-23 15:23:20 -07:00
Enrico 2768f5bfec Merge main into beta 2026-07-23 15:20:16 -07:00
Enrico Toniato f952fe0226 Canary (#1945)
* fix(docs): repair dead links flagged by link checker (#1855)

* fix(docs): repair dead links flagged by link checker

- Point CLI client docs links at docs.mcp-use.com/typescript/tooling/client-cli
  (old typescript/client/cli path 404s) in the CLI example and skills
- Remove the inspector README self-hosting link; that docs page does not exist
- Point the python README 'what should we build next' link at GitHub issues
  (old mcp-use.com page returns 410 Gone)
- Exclude generated package CHANGELOGs from lychee: historical release notes
  reference docs URLs that were valid at release time

Closes #1838

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(ci): escape and anchor lychee exclude_path regex patterns

exclude_path values are regular expressions per lychee docs; escape the
dots and anchor the patterns to match the style of existing exclude entries.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: ayaanmacmini3 <ayaanmacmini3@ayaanmacmini3s-Mac-mini.local>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* chore: enter canary prerelease mode

* chore(typescript): version packages (canary)

* fix(react): point useMcp auto proxy fallback at live inspector host (#1798)

The default autoProxyFallback proxy address was inspector.mcp-use.com,
which now 301-redirects to inspector.manufact.com. Browsers treat a
redirect on a CORS preflight as a hard failure, so the automatic
direct→proxy fallback could never connect. Default now targets the live
inspector.manufact.com proxy.

* chore(typescript): version packages (canary)

* fix(typescript): remove leftover resourceCallbacks debug log (#1878)

Every resource template registration printed a bare
"resourceCallbacks undefined" line to the console (introduced with the
completion-callbacks work, #966/#970). With MCP Apps widgets this fires
on every dev boot and every HMR reload, and the stray output actively
misled a recent bug investigation (#1875, where it was flagged as a
suspect). Remove the debug line; the value is still exercised
immediately below when building the ResourceTemplate.

Co-authored-by: ayaangazali <ayaan.gazly@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix: refresh OAuth tokens with resource

---------

Co-authored-by: Ayaan Gazali <ayaangazali.work@gmail.com>
Co-authored-by: ayaanmacmini3 <ayaanmacmini3@ayaanmacmini3s-Mac-mini.local>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: ayaangazali <ayaan.gazly@gmail.com>
2026-07-20 12:48:58 -07:00
Enrico 3d32445913 feat(assets): update SVG logos and favicon for improved design consistency
- Replaced existing SVG logos and favicon with new designs featuring updated dimensions and styles.
- Enhanced the visual representation of the assets to align with the current branding guidelines.
- Added a new `langchain.ts` file to the agent package for LangChain integration, including necessary exports and configurations.
- Updated package.json and tsup.config.ts to reflect new entry points and dependencies.
2026-07-15 09:16:04 -07:00
Andrew Khadder f7d3d10605 feat(typescript): scaffold @mcp-use/server v2 package (MCP-2601)
Greenfield v2 server SDK built on @modelcontextprotocol/server@2.0.0-beta.1
(stateless 2026-07-28 protocol) and Hono. SPEC.md in the package is the
working contract: constructor-only config, raw SDK result shapes (no response
helpers), compile-time structuredContent enforcement, Standard Schema inputs
(zod v4 / ArkType / Valibot), secure-by-default listen(). Ships with
type-level contract tests, an end-to-end smoke test, and Vercel/Railway
example deployments. Private during development — no releases.

Workspace changes: pnpm workspace + root tsconfig registration, scoped
TSDoc/jsdoc lint gates in eslint.config.js, and removal of the old
repo-level CLAUDE.md files in favor of per-package docs.

Claude-Session: https://claude.ai/code/session_01B59sx2QJ6bBBwMevCCqkr4
2026-07-02 03:29:45 -07:00
Andrew Khadder efa7fe78b2 Canary (#1719)
* fix(cli): update EnvVariable type to allow null values for sensitive rows (#1717)

- Modified the `value` property in the `EnvVariable` interface to accept `null`, indicating write-only sensitive rows where the stored value is withheld by the API.
- Adjusted the `printEnvVar` function to handle cases where `value` is `null`, ensuring proper display of sensitive information.

* chore: enter canary prerelease mode

* chore(typescript): version packages (canary)

* feat(server): add outgoing notification logging (#1674)

* chore(typescript): version packages (canary)

* fix(server): mount RFC 8414 canonical well-known paths for path-suffix issuers (#1684)

* fix(server): mount RFC 8414 canonical well-known paths for path-suffix issuers

Construct upstream OAuth/OIDC metadata URLs per RFC 8414 and OIDC
Discovery, and mount canonical path-suffixed routes on the MCP server
when the upstream issuer includes a path component.

Fixes #1576

Co-authored-by: Andrew Khadder <khandrew1@users.noreply.github.com>

* fix(server): mount OIDC discovery at root only; stop leaking error detail

Remove the unreachable, malformed OIDC path-suffix local mount (OIDC
Discovery appends the well-known segment to the issuer, so there is no
canonical form under the openid-configuration prefix, and no client flow
reaches a path-suffixed local route). Keep the RFC 8414 OAuth path-suffix
mount. Return a generic error_description to clients and log the raw
exception server-side instead of echoing it.

* style: apply prettier formatting

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Andrew Khadder <khandrew1@users.noreply.github.com>

* chore(typescript): version packages (canary)

* fix(server/oauth): broker upstream OAuth callback through /oauth/callback (#1728)

In proxy mode the server was forwarding each MCP client's redirect_uri
straight to the upstream provider, which forced every client's callback
(Claude, ChatGPT, the inspector, ...) to be pre-registered on the
provider. Instead, /authorize now sends the upstream the server's own
/oauth/callback and packs the client's redirect_uri + state into the
upstream `state` (base64url JSON, stateless). A new GET /oauth/callback
restores them and forwards the code (or upstream error) to the client's
original callback. /token rewrites redirect_uri to the brokered callback
so it matches the authorize request (RFC 6749 §4.1.3). PKCE passes
through untouched.

Also: jwksVerifier now rejects opaque (non-JWT) access tokens with an
actionable message pointing at the missing `audience`, instead of jose's
cryptic "Invalid Compact JWS".

Only `<server-domain>/oauth/callback` needs registering upstream now.

Closes MCP-2170

* fix(inspector): route localhost MCP servers through client-side chat (MCP-2419) (#1736)

* fix(inspector): route localhost MCP servers through client-side chat (MCP-2419)

In hosted mode the Chat tab streams through the managed cloud backend
(chatApiUrl), which connects to the MCP server server-side and cannot reach a
user's localhost server. The request 502s and, lacking CORS headers, surfaces
in the browser as an opaque "Failed to fetch" / CORS error.

Loopback server URLs now fall back to client-side (in-browser) chat streaming,
which already holds a direct session to the localhost server. The configure-key
empty state shows an explanatory notice telling the user the managed key can't
reach their machine and that a personal API key is needed — only in hosted mode;
the local inspector is unchanged.

The localhost check is extracted into a shared serverUrl util (with IPv6 [::1]
bracket handling) plus unit tests, and e2e tests cover the hosted+localhost
fallback, the no-cloud-call guarantee, and the notice's presence/absence.

* fix(inspector): address PR review on MCP-2419 localhost chat fix

- serverUrl: detect the full 127.0.0.0/8 loopback range (not just
  127.0.0.1), anchored so "127.example.com" is not a false positive
- serverUrl tests: cover 127.0.0.0/8 and near-loopback negatives
- e2e: stub the hosted `/api/auth/get-session` endpoint in
  enableHostedChatMode so HostedUserMenu never hits the real cloud
  backend (avoids CI flakiness/slowness)
- changeset: fix grammar

* style(inspector): prettier formatting for e2e test helpers

* chore(typescript): version packages (canary)

* fix(cli): use authoritative GitHub repo-access check for deploy (MCP-2467) (#1737)

The `mcp-use deploy` pre-flight repo-access check listed an installation's
repos and matched the target locally. That only inspected the first page, so
repos on later pages were wrongly reported inaccessible (MCP-2467); fully
paginating it (the prior behavior) hung on very large orgs.

Replace it with a single authoritative question per installation via the new
backend `GET /github/installations/:installationId/repos/:owner/:repo/access`
endpoint (a `repos.get` probe). The installation whose account matches the repo
owner is checked first, falling back to the others, preserving the
across-installations fix from MCP-2358 without paginating.

* chore(typescript): version packages (canary)

* chore(deps): bump esbuild from 0.27.1 to 0.28.1 in /libraries/typescript (#1734)

* chore(deps): bump esbuild from 0.27.1 to 0.28.1 in /libraries/typescript

Bumps [esbuild](https://github.com/evanw/esbuild) from 0.27.1 to 0.28.1.
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG-2025.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.27.1...v0.28.1)

---
updated-dependencies:
- dependency-name: esbuild
  dependency-version: 0.28.1
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: add changeset for dependabot updates

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore(typescript): version packages (canary)

* fix(typescript): silence dev widget logs when project has no widgets (#1730)

* chore(typescript): version packages (canary)

* feat : inspector add scroll-to-bottom button (#1538)

* inspector: add scroll-to-bottom button

* fix(inspector): center chat scroll button

---------

Co-authored-by: Andrew Khadder <andrew@manufact.com>

* chore(typescript): version packages (canary)

* fix(cli): cleanly unsubscribe on Ctrl+C (SIGINT) (#1687)

* fix(cli): add SIGINT handler to cleanly unsubscribe from resource

Addresses #1686

* chore: add cli changeset

---------

Co-authored-by: Andrew Khadder <andrew@manufact.com>

* chore(typescript): version packages (canary)

* fix(inspector): update emulate oauth callback (#1743)

* refactor: centralize screenshot handling and add REPL screenshot support (#1592)

* refactor: centralize screenshot handling and add REPL screenshot support

* chore: fix knip checks

* chore: drop knip version ignore

---------

Co-authored-by: Andrew Khadder <andrew@manufact.com>

* chore(typescript): version packages (canary)

* fix(api): update base URL for remote API calls to manufact.com (#1745)

* chore(config): add Langfuse Cloud API endpoints to exclusion list in lychee.toml

- Updated the `lychee.toml` configuration file to include Langfuse Cloud API endpoints in the exclusion list, preventing 403 errors from bot protection during CI processes. This change ensures valid defaults for API interactions.

* fix(workflow): remove unnecessary flag from pnpm install command in CI configuration

- Updated the `bump-mcp-use-reusable.yml` workflow file to remove the `--config.dangerously-allow-all-builds=true` flag from the `pnpm install` command, streamlining the installation process during CI runs.

* fix(api): update base URL for remote API calls to manufact.com

- Changed the default base URL from 'https://cloud.mcp-use.com' to 'https://cloud.manufact.com' across multiple files, including MCPAgent and RemoteAgent initializations, ensuring consistency in API endpoint references.

* chore(typescript): version packages (canary)

* feat(cli): add support for custom Dockerfile path in deployment options (#1746)

* chore(config): add Langfuse Cloud API endpoints to exclusion list in lychee.toml

- Updated the `lychee.toml` configuration file to include Langfuse Cloud API endpoints in the exclusion list, preventing 403 errors from bot protection during CI processes. This change ensures valid defaults for API interactions.

* fix(workflow): remove unnecessary flag from pnpm install command in CI configuration

- Updated the `bump-mcp-use-reusable.yml` workflow file to remove the `--config.dangerously-allow-all-builds=true` flag from the `pnpm install` command, streamlining the installation process during CI runs.

* feat(cli): add support for custom Dockerfile path in deployment options

- Introduced a new CLI option `--dockerfile` to specify a non-default Dockerfile path relative to the project root.
- Updated the `DeployOptions` interface to include the `dockerfile` property.
- Enhanced deployment command output to display the specified Dockerfile path, improving user feedback during deployment processes.

* refactor(cli): improve console log formatting for Dockerfile output

- Reformatted the console log statement for the Dockerfile option in the deploy command to enhance readability by breaking it into multiple lines. This change aims to maintain consistent code style and improve maintainability.

* chore(typescript): version packages (canary)

* Remove obsolete OAuth proxy callback changeset

* chore(typescript): version packages (canary)

* docs: update canary changelogs

* fix(cli): allow empty env var updates (#1750)

* chore(config): add Langfuse Cloud API endpoints to exclusion list in lychee.toml

- Updated the `lychee.toml` configuration file to include Langfuse Cloud API endpoints in the exclusion list, preventing 403 errors from bot protection during CI processes. This change ensures valid defaults for API interactions.

* fix(workflow): remove unnecessary flag from pnpm install command in CI configuration

- Updated the `bump-mcp-use-reusable.yml` workflow file to remove the `--config.dangerously-allow-all-builds=true` flag from the `pnpm install` command, streamlining the installation process during CI runs.

* fix(cli): allow empty env var updates

* Add changeset for empty env value updates

---------

Co-authored-by: Enrico <2827496+tonxxd@users.noreply.github.com>

* chore(typescript): version packages (canary)

* chore(deps): bump tar from 7.5.11 to 7.5.16 in /libraries/typescript (#1744)

* chore(config): add Langfuse Cloud API endpoints to exclusion list in lychee.toml

- Updated the `lychee.toml` configuration file to include Langfuse Cloud API endpoints in the exclusion list, preventing 403 errors from bot protection during CI processes. This change ensures valid defaults for API interactions.

* fix(workflow): remove unnecessary flag from pnpm install command in CI configuration

- Updated the `bump-mcp-use-reusable.yml` workflow file to remove the `--config.dangerously-allow-all-builds=true` flag from the `pnpm install` command, streamlining the installation process during CI runs.

* chore(deps): bump tar from 7.5.11 to 7.5.16 in /libraries/typescript

Bumps [tar](https://github.com/isaacs/node-tar) from 7.5.11 to 7.5.16.
- [Release notes](https://github.com/isaacs/node-tar/releases)
- [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/isaacs/node-tar/compare/v7.5.11...v7.5.16)

---
updated-dependencies:
- dependency-name: tar
  dependency-version: 7.5.16
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: add changeset for dependabot updates

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Enrico Toniato <2827496+tonxxd@users.noreply.github.com>
Co-authored-by: Enrico <2827496+tonxxd@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore(typescript): version packages (canary)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Enrico Toniato <2827496+tonxxd@users.noreply.github.com>
Co-authored-by: Enrico Toniato <2827496+tonxxd@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Tiwari <144548881+dhruvtiwari6@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Andrew Khadder <khandrew1@users.noreply.github.com>
Co-authored-by: Pietro Zullo <62951181+pietrozullo@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: kalpchaniyara <kalpchaniyara.2006@gmail.com>
Co-authored-by: Neha Prasad <nehaa9863pd@gmail.com>
Co-authored-by: Arpit Maurya <arpitbabu802@gmail.com>
Co-authored-by: 落尘 <cuidong111@gmail.com>
2026-06-16 09:41:20 -07:00
Parship Chowdhury 43ddbaa3a6 fix(python): correct dev setup docs in CLAUDE.md (#1689)
Signed-off-by: Parship Chowdhury <parshipchowdhury@gmail.com>
2026-06-10 15:04:15 +02:00
Parship Chowdhury 4a64d99fd7 fix(python): use python3 instead of python3.11 in pre-commit config (#1690)
Signed-off-by: Parship Chowdhury <parshipchowdhury@gmail.com>
2026-06-10 10:31:56 +02:00
Enrico Toniato bc5add402f fix: replace broken doc hosts with canonical mcp-use.com/docs URLs (#1366)
- docs.mcp-use.io/python/changelog/changelog timed out in link checker
- mcp-use.dev caused HTTP/2 protocol errors
Both replaced with equivalent paths on mcp-use.com/docs, already the
canonical host used across the rest of the monorepo.

Made-with: Cursor
2026-04-20 10:03:00 +02:00
Pietro Zullo e4fedebccb feat(python): add Context.elicit_url() for URL mode elicitation (#1225)
The MCP SDK supports URL mode elicitation via session.elicit_url(), but
the mcp-use Context only exposed form mode via ctx.elicit(). This adds a
clean ctx.elicit_url(message, url) wrapper so Python server authors
don't need to drop down to the raw session API.

- Auto-generates elicitation_id if not provided
- Tracks telemetry as "elicit_url"
- Forwards related_request_id from context
- Includes docstring with usage example
- 6 unit tests covering delegation, actions, telemetry, and ID generation
2026-03-23 17:20:59 +01:00
pietrozullo fc918e5bc7 python/release/1.7.0 2026-03-17 14:42:18 +01:00
Pietro Zullo 2ddad74dab fix(python): convert MCP tool results to LangChain content blocks (#1192)
* fix(python): convert MCP tool results to LangChain content blocks

Previously, tool results were converted using `str(tool_result.content)`,
which produced Python repr strings like
`[TextContent(type='text', text='...')]` instead of the actual content.

Now properly maps MCP content types to LangChain format:
- TextContent → plain string or {"type": "text", ...}
- ImageContent → {"type": "image", "source_type": "base64", ...}
- AudioContent → {"type": "audio", "source_type": "base64", ...}
- EmbeddedResource → text or file block depending on resource type

Single TextContent results (the most common case) are returned as
plain strings for backward compatibility.

* test(python): cover langchain tool content conversion

* style(python): format langchain adapter

* test(python): cover langchain block tool messages
2026-03-16 08:59:16 +01:00
Pietro Zullo 30b23271d5 fix(python): respect configured inspector path (#1176)
* fix(python): respect configured inspector path

* fix(python): treat inspector path as a base prefix

* fix(python): format inspector fixes for ruff

* fix(ci): run conformance with node 22

* fix(ci): fail conformance runs with empty results

* chore(ci): drop inline conformance result validation

* docs(python): clarify inspector path behavior
2026-03-09 14:24:53 +01:00
Enrico Toniato 8d55603972 Canary (#1166)
* feat(python): add E2E testing for Python server in CI workflow

- Introduced a new job in the GitHub Actions workflow to run end-to-end tests against the Python MCP server.
- Updated the inspector.py to allow overriding the CDN base URL via an environment variable.
- Added a new script command for running Python E2E tests in the package.json.
- Enhanced documentation to include instructions for running Python server E2E tests.

* fix(inspector): skip proxy when inspector is served from the MCP server itself

When the inspector is embedded in a Python (or other) MCP server, the
window.location.origin matches the MCP server's origin, so
/inspector/api/proxy doesn't exist there. Routing auto-connect through
that missing proxy caused silent connection failures.

Now proxyAddress is only set when the inspector origin differs from the
target URL's origin (i.e. the inspector has its own server running).

Also add echo tool to server_example.py so python.test.ts can pass.

* fix(inspector): detect proxy availability via runtime config injection

Inject window.__MCP_PROXY_URL__ from the inspector server when it serves
the HTML. When served from a Python/custom MCP server (same origin), the
flag is absent and autoProxyFallback is disabled so no proxy is used.

- Add proxyUrl to RuntimeConfig in shared-static.ts
- Default to /inspector/api/proxy when inspector server serves
- Read __MCP_PROXY_URL__ in App.tsx and configure defaultAutoProxyFallback
- Disable autoProxyFallback when no proxy is available (no hosted fallback)

* ci: trigger inspector E2E workflow on PRs to canary/main

* ci: temporarily disable mix/prod/builtin E2E jobs for Python testing

* ci: re-enable all E2E jobs, workflow_dispatch only

* ci: re-enable E2E jobs for Python testing in CI workflow

* chore: enter canary prerelease mode

* chore(typescript): version packages (canary)

* fix(inspector): resolve auto-connect issues for embedded servers

This patch release addresses the auto-connect functionality of the inspector when served from an MCP server. Key changes include skipping the proxy when the inspector's origin matches the MCP server's origin and detecting proxy availability through runtime configuration. Additionally, the mcp-use package has been updated to version 1.21.2.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-03-06 17:24:26 +01:00
Pietro Zullo 0ac1c60a60 feat(python): add mcp_logs_only option to hide non-MCP HTTP access logs (#1164)
* feat(python/server): add mcp_logs_only option to suppress HTTP access logs

When mcp_logs_only=True, all uvicorn access logs are suppressed. MCP
protocol logs (printed directly by MCPLoggingMiddleware) continue to
show. This eliminates the duplicate INFO: lines for MCP requests and
hides non-MCP HTTP traffic (/docs, /inspector, static files).

The implementation is simple: MCPAccessFormatter returns an empty string
when the flag is set, since the middleware already handles MCP logging
via direct stdout prints.

Closes #1162

* fix(python/server): use filter instead of empty string to suppress access logs

Replace the formatter returning "" (which still outputs a blank line)
with a proper MCPLogsOnlyFilter that drops log records entirely.

* docs: update

* docs(python): document mcp_logs_only option in server logging docs
2026-03-06 14:39:21 +01:00
Pietro Zullo 1a3dcfd632 feat(python): auto-retry next available port when default is in use (#1163)
* feat(python/server): auto-retry next available port when default is in use

Add port availability checking before starting uvicorn. When the
requested port is occupied, the server automatically tries the next
port (up to 10 retries) instead of crashing.

Refs #1161

* test(python/server): add unit tests for port retry helpers

Tests for _is_port_available and _find_available_port covering:
- Port available/unavailable detection
- Skipping to next port when current is in use
- RuntimeError when all ports exhausted

* docs(python): document automatic port retry in server running docs
2026-03-06 14:39:11 +01:00
Vincenzo Reina d344233c50 feat(python): add create-mcp-use CLI with rich UI and dependency install (#1097)
* Add uvx create-mcp-use command

* Update docs

* Add docs

* feat(python/cli): improve create-mcp-use with rich UI, dependency install, and telemetry

- Use rich for colored output, spinner, and panel for get-started instructions
- Add ASCII logo matching the TypeScript CLI
- Prompt user to install dependencies after scaffolding (detects uv/pip)
- Add --install and --no-install flags for non-interactive use
- Capture install output to keep terminal clean
- Add CreateMCPUseEvent telemetry to track CLI usage
- Fix starter template pyproject.toml hatch build config for installability

* feat(python/server): auto-retry next available port when default is in use

Add port availability checking before starting uvicorn. When the
requested port is occupied, the server automatically tries the next
port (up to 10 retries) instead of crashing.

Refs #1161

* fix(python/cli): fix linting errors in create-mcp-use CLI

* Revert "feat(python/server): auto-retry next available port when default is in use"

This reverts commit baf3d3233e.

* fix(python/cli): address PR review feedback

- Fix ruff format issues in cli.py
- Fix "Cli" → "CLI" in docs title
- Fix "a MCP" → "an MCP" grammar in quickstart

* docs(python): regenerate API docs for CLI module

* docs: update

---------

Co-authored-by: pietrozullo <pietro.zullo@gmail.com>
2026-03-06 12:25:19 +01:00
Pietro Zullo b2d9425446 fix: replace examples symlinks with navigable READMEs (#1160)
* fix: replace examples symlinks with redirect READMEs

GitHub's web UI renders symlinks as plain text showing the target path
instead of navigating to the linked directory. Replace the symlinks
with directories containing README files that link to the actual
example directories, so clicking through works on GitHub.

Closes MCP-865

* fix: add example READMEs with descriptions to library directories

Add README.md files to the actual example directories so GitHub
renders them when browsing. Each README lists all examples with
short descriptions in table format.

- libraries/python/examples/README.md
- libraries/typescript/packages/mcp-use/examples/README.md
- Update redirect READMEs in examples/python and examples/typescript

Closes MCP-865
2026-03-06 11:17:59 +01:00
Pietro Zullo e935514fc7 feat(python): add icons parameter to MCPServer constructor (#1147)
* fix(python/server): simplify tool JSON Schema for Optional parameters

Pydantic generates {"anyOf": [{"type": "T"}, {"type": "null"}]} for
Optional[T] tool parameters. While valid JSON Schema 2020-12, this
pattern breaks description rendering in the MCP Inspector UI and fails
Gemini API validation (requires top-level type field). MCP signals
optionality via the required array, making the anyOf/null wrapper
redundant.

- Add simplify_optional_schema() utility that collapses nullable anyOf
  into flat {"type": "T"} while preserving description, default, title
- Override MCPServer.add_tool() to apply simplification after Pydantic
  generates the schema
- Add 12 unit tests for the schema simplifier (test_json_schema.py)
- Add 23 unit tests for tool schema output (test_list_tool_format.py)
- Update server_example.py with representative parameter patterns
  including Literal enum types

* docs(python/server): add parameter types and JSON Schema section to tools docs

Document the Python-to-JSON-Schema type mapping, required/optional/nullable
parameter patterns, and Literal enum usage. Includes a note explaining the
anyOf/null simplification that mcp-use applies automatically.

* feat(python/server): add icons parameter to MCPServer constructor

Pass through the icons parameter to FastMCP so server-level icons can
be set directly in the MCPServer constructor.

* docs(python/server): document icons parameter in server overview

* docs(python): update server example with icons and Literal enum params

* style: format server_example.py

* test(python): add unit tests for icons constructor parameter

* docs: regenerate API reference for icons param
2026-03-05 10:17:58 +01:00
Pietro Zullo ccfb07a8ee fix(python): simplify tool JSON Schema for Optional parameters (#1141)
* fix(python/server): simplify tool JSON Schema for Optional parameters

Pydantic generates {"anyOf": [{"type": "T"}, {"type": "null"}]} for
Optional[T] tool parameters. While valid JSON Schema 2020-12, this
pattern breaks description rendering in the MCP Inspector UI and fails
Gemini API validation (requires top-level type field). MCP signals
optionality via the required array, making the anyOf/null wrapper
redundant.

- Add simplify_optional_schema() utility that collapses nullable anyOf
  into flat {"type": "T"} while preserving description, default, title
- Override MCPServer.add_tool() to apply simplification after Pydantic
  generates the schema
- Add 12 unit tests for the schema simplifier (test_json_schema.py)
- Add 23 unit tests for tool schema output (test_list_tool_format.py)
- Update server_example.py with representative parameter patterns
  including Literal enum types

* docs(python/server): add parameter types and JSON Schema section to tools docs

Document the Python-to-JSON-Schema type mapping, required/optional/nullable
parameter patterns, and Literal enum usage. Includes a note explaining the
anyOf/null simplification that mcp-use applies automatically.

* fix(python/server): address PR review comments on json_schema.py

- Fix _simplify_property docstring: says "in place" but returns new dict
- Fix simplify_optional_schema docstring: document fast-path return when
  no properties exist (returns original, not a copy)
- Wrap dict comprehension for line length

* style: format server_example.py

* docs: regenerate API reference for json_schema module
2026-03-05 09:24:46 +01:00
Pietro Zullo 2d13a2310c chore(python): remove accidentally generated python/python directory (#1148) 2026-03-05 09:24:36 +01:00
不做了睡大觉 4179a9c45c fix(python): use WeakSet for resource subscriptions to prevent memory leak on client disconnect (#1093)
* fix: use WeakSet for resource subscriptions to prevent memory leak on client disconnect

Fixes #1092

Previously, resource subscriptions tracked sessions by storing id(session)
integers in plain sets. When clients disconnected without explicitly
unsubscribing, these integer IDs accumulated indefinitely since there was
no cleanup mechanism for dropped connections.

This change replaces the dict[str, set[int]] with dict[str, WeakSet],
storing weak references to session objects directly. When a session is
garbage-collected (after disconnect), its entry is automatically removed
from all subscription sets.

This also simplifies notify_resource_updated() — instead of iterating all
active sessions and checking membership by id, we now iterate the WeakSet
subscribers directly, which is both correct and more efficient.

* style: use idiomatic emptiness check for WeakSet

Replace `if not len(subscribers)` with `if not subscribers` for consistency
with the existing check in notify_resource_updated().

* fix: clean up empty subscription entries + add unit tests

- Clean up empty dict entries in notify_resource_updated() after all
  sessions for a URI are GC'd, preventing stale keys from accumulating
- Add 4 unit tests for GC-driven subscription cleanup:
  - test_subscription_cleanup_after_session_gc
  - test_notify_skips_gc_collected_sessions
  - test_notify_does_not_crash_when_all_sessions_gone
  - test_multiple_uris_independent_cleanup

---------

Co-authored-by: User <user@example.com>
Co-authored-by: pietrozullo <pietro.zullo@gmail.com>
2026-03-03 09:59:24 +01:00
Pietro Zullo 869e56fcf4 fix(python): register debug routes when debug=True passed to run() (#1114)
* fix(python): register debug routes when debug=True passed to run()

When MCPServer was created with debug=False (default) and run(debug=True)
was called, debug routes (/docs, /inspector, /openmcp.json) were never
registered because _add_dev_routes() only ran during __init__.

Now run(debug=True) calls _add_dev_routes() and rebuilds the Starlette
app so routes are available. Also removes dead code in ServerRunner that
could never execute due to the same ordering issue.

Closes #1099

* docs: regenerate API reference after removing debug from ServerRunner.run()

The debug parameter was removed from ServerRunner.run() since debug mode
is now fully handled in MCPServer.run() before the runner is invoked.
2026-02-27 15:32:04 +01:00
pederzh 9ad9ff16a5 Merge branch 'chore/update-readme' 2026-02-18 23:43:43 -08:00
pietrozullo 7c3b6c2e1f feat(docs): enhance Python server documentation with examples for tools, prompts, and resources
- Added detailed examples for defining tools, prompts, and resources in Python, showcasing their usage with annotations and context.
- Updated README to include a Python server example for weather information retrieval.
- Improved clarity on prompt and resource definitions, including argument descriptions and JSON-RPC responses.
- Enhanced documentation for better understanding of dynamic resources and tool functionalities.
2026-02-18 11:16:16 -08:00
pederzh ce6bedcb68 chore: fix sub-READMEs for consistency with root README
Update terminology, fix stale references, and align sub-package
READMEs with the refactored root README.
2026-02-15 23:18:07 -08:00
Pietro Zullo 4973930df0 chore(python): add dependency policy and roadmap (#1020)
* chore(python): add DEPENDENCY_POLICY, ROADMAP, and SECURITY for Tier 1 compliance

Required by the MCP SDK Tiering System:
- DEPENDENCY_POLICY.md: Python version support, MCP SDK update policy, dependency cadence
- ROADMAP.md: Q1-Q2 2026 plan with conformance status and upcoming features
- SECURITY.md: Vulnerability reporting process and response timelines

Ref: https://modelcontextprotocol.io/community/sdk-tiers

* chore(python): scope ROADMAP to Python only, use GitHub security advisories

- Remove TypeScript items from ROADMAP, focus on Python SDK 2.0 architecture
- Remove non-SDK items (caching middleware, uvx template, MCP-UI)
- Replace email-based security reporting with GitHub private vulnerability reporting

* fix(python): correct CONTRIBUTING.md relative path in ROADMAP

* chore(python): remove duplicate SECURITY.md, repo root already has one
2026-02-15 19:21:01 -08:00
Pietro Zullo 6160a6bdde fix(python): achieve 100% client conformance (20/20) — fix sse-retry (#1019)
The conformance client was just sleeping during sse-retry instead of
calling the test_reconnection tool. The MCP SDK transport already handles
SSE reconnection with Last-Event-ID correctly — we just needed to
trigger the stream closure by calling the tool.

Also added comprehensive documentation to the conformance client explaining:
- How the conformance framework works
- What each scenario expects
- Why each configuration decision was made
- Links to spec references for each scenario

Python client conformance: 20/20 (100%)
2026-02-15 17:03:19 -08:00
Pietro Zullo 5c0b35afd9 fix(python): replace deprecated streamablehttp_client with streamable_http_client (#1017)
* fix(python): replace deprecated streamablehttp_client with streamable_http_client

The MCP SDK deprecated streamablehttp_client (camelCase) in favor of
streamable_http_client (snake_case). The new API takes a pre-configured
httpx.AsyncClient instead of individual params.

Changes:
- Create httpx.AsyncClient with auth, headers, timeouts via factory
- Pass it to streamable_http_client(url, http_client=client)
- Manage httpx client lifecycle in _close_connection
- Default httpx_client_factory to create_mcp_http_client (no more None)

Closes MCP-1379

* fix: use logger.warning for cleanup errors (consistent with other connection managers)

* chore: bump mcp minimum version to 1.24.0 (streamable_http_client introduced)

* docs

* docs

* docs: fix memory address in generated docs (use None default instead of function reference)
2026-02-15 16:45:00 -08:00
Pietro Zullo 0eeeee6d1a fix(python): improve client conformance (pre-registration, CIMD, scope step-up) (#1011)
* fix(python): handle pre-registration and CIMD in conformance client

Configure OAuthClientProvider correctly for each auth scenario:
- Pre-registration: populate storage with client_id/secret from MCP_CONFORMANCE_CONTEXT
- CIMD: pass client_metadata_url for URL-based client IDs
- Use asyncio.get_running_loop() for reliable future creation

* fix(python): use correct CIMD URL for conformance test (conformance-test.local)

* fix(python): exercise tools in auth scenarios to trigger scope step-up

The conformance client was doing nothing after connecting in auth scenarios,
so the scope-step-up 403 flow never triggered. Now calls tools after auth
so httpx's OAuthClientProvider can handle the re-authorization.

Client conformance: 19/20 (was 18/20)
2026-02-15 16:13:35 -08:00
Pietro Zullo 29f23adda1 feat: conformance test infrastructure for server + client (#1008)
- Update Python conformance server with all required tool/resource/prompt names
- Add Python conformance client with headless OAuth for auth scenarios
- Add integration test (test_conformance.py) with 11 tests covering both runners
- Update CI workflow: test-type 'both', separate clients list
- Add SEP-1330 enum elicitation to TypeScript conformance server

Python server conformance: 30/30 (100%)
Python client conformance: 16/20 (80%) — 4 auth gaps in upstream SDK
2026-02-14 18:54:59 -08:00
Pietro Zullo fda92d4ebb test(python): add integration tests for resource subscriptions (#1007)
Tests the full subscribe -> update -> notification flow:
- Client subscribes, server updates via tool, client receives notification
- Client unsubscribes, server updates, no notification received

Adds subscribable resource (data://live) and set_live_data tool to primitive server.
2026-02-14 18:54:18 -08:00
Pietro Zullo a9bc4db3ae feat(python): add protocol handlers for logging, completions, subscriptions, and DNS protection (#1004)
* feat(python): add protocol handlers for logging, completions, subscriptions, and DNS protection

Server SDK changes:
- logging/setLevel: stores client level, Context.log() filters by RFC 5424 severity
- completion/complete: default empty handler, overridable via mcp.completion()
- resources/subscribe + unsubscribe: tracks per-session subscriptions
- notify_resource_updated(): broadcasts to all subscribed sessions via WeakSet
- dns_rebinding_protection: explicit constructor parameter (default: False)
- Capabilities patch for subscribe=True

Middleware:
- Added hooks: on_set_logging_level, on_subscribe_resource, on_unsubscribe_resource, on_complete

Tests:
- 9 unit tests for log level filtering (RFC 5424)
- Updated DNS protection tests for explicit flag

Docs:
- logging.mdx: MCP protocol logging section with level filtering
- resources.mdx: subscription section with example
- middleware.mdx: new hooks documented

Refs:
- https://modelcontextprotocol.io/specification/2025-11-25/server/utilities/logging
- https://modelcontextprotocol.io/specification/2025-11-25/server/resources#subscriptions

* style: format adapter files for ruff 0.15
2026-02-14 18:53:30 -08:00
Pietro Zullo e6ba394ec7 chore: format adapter files for ruff 0.15 + remove docs PR comment spam (#1003)
- Format 3 adapter files to match ruff 0.15 (CI version)
- Remove the PR comment step from docs.yml that spammed every push
2026-02-14 18:53:20 -08:00
Pietro Zullo 5e279873df fix(python): propagate verify parameter to HTTPConnector (#914)
The `verify` parameter on MCPClient was not being passed to
`create_connector_from_config` in the `create_session` method,
causing SSL certificate errors when using `verify=False` with
HTTP-based MCP servers.

Closes #913
2026-01-29 15:14:14 +01:00
pietrozullo be5f4d7490 python/release1.6.0 2026-01-22 12:58:01 +01:00
Pietro Zullo d789a92b4b feat(server): Bearer Token authentication for Python MCP server (#841)
* Fix DNS rebinding protection for cloud/proxy deployments

- Add host/port parameters to MCPServer.__init__() and pass to FastMCP
- Default host to "0.0.0.0" (cloud-friendly, disables DNS protection)
- "127.0.0.1" auto-enables DNS protection (handled by FastMCP)
- run() can override host/port, falls back to __init__ values
- Add comprehensive docstring to __init__() explaining parameters
- Update documentation

This fixes 421 Misdirected Request errors when running behind reverse
proxies (Cloudflare, nginx, etc.) where the Host header doesn't match
the auto-configured allowed_hosts for localhost.

* Fix DNS rebinding protection for cloud/proxy deployments

- Add host/port parameters to MCPServer.__init__() and pass to FastMCP
- Default host to "0.0.0.0" (cloud-friendly, disables DNS protection)
- "127.0.0.1" auto-enables DNS protection (handled by FastMCP)
- run() can override host/port and reconfigures DNS protection accordingly
- Rebuild app when host changes in run() to apply new security settings
- Add comprehensive docstring to __init__() explaining parameters
- Add unit tests for host/port configuration and run() overrides
- Update documentation

This fixes 421 Misdirected Request errors when running behind reverse
proxies (Cloudflare, nginx, etc.) where the Host header doesn't match
the auto-configured allowed_hosts for localhost.

* ruff lint

* Bump mcp minimum version to 1.23.0

Required for TransportSecuritySettings and DNS rebinding protection
auto-configuration feature that was added in v1.23.0.

* feat(server): add bearer token authentication for Python MCP server

Add HTTP-layer bearer token authentication that returns proper 401 responses.

- BearerAuthProvider: abstract base class with verify_token() method
- AccessToken: model with token, claims, and scopes fields
- AuthMiddleware: Starlette middleware returning HTTP 401 for invalid tokens
- get_access_token() / require_auth(): context helpers for tools

Usage:
```python
class MyAuth(BearerAuthProvider):
    async def verify_token(self, token: str) -> AccessToken | None:
        if token != "secret":
            return None
        return AccessToken(token=token, claims={"user": "alice"})

server = MCPServer(name="my-server", auth=MyAuth())
```

Closes #840

* autogenerate docs

* test(server): add unit and integration tests for bearer token auth

Unit tests:
- AccessToken model creation and serialization
- BearerAuthProvider abstract class and subclassing
- get_access_token/require_auth context helpers
- AuthMiddleware 401 responses, path exclusion, CORS

Integration tests:
- MCPClient connecting to bearer auth server with valid token
- Connection failure with invalid/missing token
- Tool access to user claims and scopes

* fix(server): address code review feedback for bearer auth

- Fix CORS security: allow_credentials=False with allow_origins=["*"]
- Remove dead try/except import for auth module
- Remove PII (email) from debug logs
- Add comment explaining broad exception handling in verify_token
- Add /openmcp.json to docs excluded paths list
- Remove set_access_token from public API (internal only)
- Create AuthenticationError instead of using ValueError
- Skip middleware tests on older httpx versions (TestClient compat)

* docs: update API documentation for auth module

* fix(server): address Copilot review feedback

- Fix bearer.mdx: require_auth raises AuthenticationError, not ValueError
- Fix API docs: claims and scopes are optional with defaults, not required
- Remove deprecated SSE transport from bearer_auth_server.py test server

* autogenerate docs

* fix(server): address renvins review feedback

- Improve bearer.mdx claims documentation with explanation and examples
- Remove unnecessary cast() for AuthMiddleware in server.py
- Refactor auth tests to use pytest fixtures for cleaner setup/teardown

* docs(auth): clarify that all MCP endpoints are automatically protected

- Add "What Gets Protected" section explaining automatic protection
- Clarify that get_access_token/require_auth are for accessing token data, not protection
- Update examples to show proper usage pattern
- Improve Note at bottom to be clearer

* fix(auth): prevent path prefix bypass in auth middleware

Security fix: Use exact path matching or segment-based prefix matching
instead of simple startswith() to prevent auth bypass attacks.

Before: /docs-secret would bypass auth because it starts with /docs
After: Only /docs and /docs/* bypass auth, /docs-secret requires auth

Added tests for path matching security edge cases.

* refactor(auth): update import paths for authentication components

- Changed import statements in multiple documentation files and source files to reflect the new structure, moving authentication-related imports to the `auth` submodule.
- Updated examples to ensure clarity and consistency in usage patterns for `BearerAuthProvider`, `AccessToken`, `get_access_token`, and `require_auth`.
2026-01-21 17:53:38 +01:00
Enrico Toniato 21ca5d8013 fix(docs): update links in documentation for consistency and accuracy
- Corrected the MCP Specification link in the TypeScript client documentation.
- Updated relative paths to the CONTRIBUTING.md file in Python and TypeScript README files.
- Adjusted links in various README files to ensure they point to the correct resources, including examples and specifications.
- Removed outdated deployment instructions from the Inspector package README.
2026-01-20 11:21:45 +01:00
Pietro Zullo 79d017bdc2 fix(python): DNS rebinding protection for cloud/proxy deployments (#825)
* Fix DNS rebinding protection for cloud/proxy deployments

- Add host/port parameters to MCPServer.__init__() and pass to FastMCP
- Default host to "0.0.0.0" (cloud-friendly, disables DNS protection)
- "127.0.0.1" auto-enables DNS protection (handled by FastMCP)
- run() can override host/port, falls back to __init__ values
- Add comprehensive docstring to __init__() explaining parameters
- Update documentation

This fixes 421 Misdirected Request errors when running behind reverse
proxies (Cloudflare, nginx, etc.) where the Host header doesn't match
the auto-configured allowed_hosts for localhost.

* Fix DNS rebinding protection for cloud/proxy deployments

- Add host/port parameters to MCPServer.__init__() and pass to FastMCP
- Default host to "0.0.0.0" (cloud-friendly, disables DNS protection)
- "127.0.0.1" auto-enables DNS protection (handled by FastMCP)
- run() can override host/port and reconfigures DNS protection accordingly
- Rebuild app when host changes in run() to apply new security settings
- Add comprehensive docstring to __init__() explaining parameters
- Add unit tests for host/port configuration and run() overrides
- Update documentation

This fixes 421 Misdirected Request errors when running behind reverse
proxies (Cloudflare, nginx, etc.) where the Host header doesn't match
the auto-configured allowed_hosts for localhost.

* ruff lint

* Bump mcp minimum version to 1.23.0

Required for TransportSecuritySettings and DNS rebinding protection
auto-configuration feature that was added in v1.23.0.
2026-01-19 15:32:58 +01:00
Pietro Zullo d8d319c940 fix(python/server): improve debug and pretty_print_jsonrpc behavior (#814)
* fix(python/server): improve debug and pretty_print_jsonrpc behavior

- Make pretty_print_jsonrpc work independently of debug_level
  (previously required DEBUG=2 environment variable)
- Rename run_debug to debug in server.run() for consistency
- Make run(debug=True) override server's debug_level if it was 0
- Remove aggressive signal handlers that broke thread compatibility
  (uvicorn handles SIGINT/SIGTERM gracefully)
- Update all documentation to use new debug parameter name

* refactor(python/server): remove unused lupo_tool function from server_example.py

* docs: update signals API reference after simplification

* refactor: remove unused signals.py module

uvicorn already handles SIGINT/SIGTERM gracefully, so custom signal
handlers are unnecessary. Removed the signals.py file and all references
to setup_signal_handlers().

* chore: remove analysis files
2026-01-14 18:43:25 +01:00
Vincenzo Reina 4997674559 feat(python): Intercept MCP handshake with on_initialize middleware (#769)
* Wrap server session from MCP

* Update server and middleware

* Update middleware example

* Fix formatting and linting

* Update docs

* Fix monkeypatch for tests

* Update docs and remove comment

* feat(python): add tests, docs, and docstrings for on_initialize middleware

- Add 13 unit tests covering dispatch, chain order, rejection, and context enrichment
- Rewrite middleware.mdx documentation with Mintlify components (Tabs, Tips, Cards)
- Add comprehensive docstring to MiddlewareServerSession documenting single-server-per-process limitation
- Add docs/CLAUDE.md with documentation improvement guidelines
- Regenerate API documentation

* docs: highlight typed context feature in middleware docs

* example: add ClientCapabilitiesGuard demonstrating typed context

* style: fix linting in middleware example

* docs(examples): add comprehensive docstrings to middleware_example.py

- Add module docstring explaining key concepts and middleware hooks
- Document each middleware class with typed context details
- Organize code with section headers (CONNECTION, REQUEST, TOOL-SPECIFIC)
- Add ClientCapabilitiesGuard example showing typed context usage

---------

Co-authored-by: pietrozullo <pietro.zullo@gmail.com>
2026-01-14 16:47:57 +01:00
Inchara J c990faf76b fix(python): add timeout mechanism to ConnectionManager.stop() (#726)
* fix(python): add timeout mechanism to ConnectionManager.stop()

Add timeout parameter (default: 30s) to stop() method to prevent infinite hangs
during application shutdown. Resolves issue #562.

Changes:
- Add timeout parameter to stop() with 30 second default
- Wrap task wait with asyncio.wait_for() to enforce timeout
- Wrap cleanup event wait with asyncio.wait_for() to enforce timeout
- Force cleanup on timeout by clearing connection and setting done event
- Add appropriate warning/error logging on timeout

Tests:
- Add 10 comprehensive unit tests for timeout scenarios
- All 158 unit tests pass
- Manual end-to-end testing verified

This ensures graceful shutdown even when cleanup hangs in production.

* updated with copilot suggested edits

* ruff checks passed

* Improve timeout handling in ConnectionManager.stop()

- Move 'import time' to module level
- Use CancelledError consistently (Python 3.11+ style)
- Treat timeout <= 0 or None as infinite wait (no timeout)
- Add elapsed time to timeout warning logs
- Add tests for negative/zero/None timeout behavior

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update ConnectionManager.stop() API reference with timeout parameter

---------

Co-authored-by: pietrozullo <pietro.zullo@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 18:04:08 +01:00
pietrozullo 6d04f70106 release/python1.5.2 2026-01-12 13:50:07 +01:00
Luigi Pederzani b45d9663ec feat(python): introduce roots support in MCPClient and Server (#751)
* fix(python): expose client capabilities to MCP servers

Add list_roots_callback support to Python connectors to properly
advertise the roots capability during MCP initialization handshake.

Previously, the Python library was not exposing any client capabilities
because the list_roots_callback was not being passed to ClientSession.
This fix ensures the roots capability is always advertised, bringing
the Python library in line with the TypeScript implementation.

Changes:
- Add roots and list_roots_callback params to BaseConnector
- Add get_roots() and set_roots() methods for managing roots
- Pass list_roots_callback to ClientSession in all connectors
- Export Root type from connectors module
- Update unit tests to expect list_roots_callback parameter

Closes MCP-1063

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(python): add roots and list_roots_callback params to connectors

- Add roots and list_roots_callback parameters to StdioConnector,
  HttpConnector, and SandboxConnector constructors
- Add comprehensive unit tests for client capabilities exposure
- Tests verify roots capability, get_roots(), set_roots(), and
  that all callbacks are correctly passed to ClientSession

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: fix import sorting and update API documentation

- Fix import sorting in test_client_capabilities.py (ruff)
- Regenerate API documentation for updated connector classes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(python): add list_roots() method to server Context

Allow MCP servers to request the list of roots from connected clients
via ctx.list_roots(). This follows the same pattern as ctx.sample()
and ctx.elicit() for server-to-client requests.

* feat(python): add roots params to MCPClient and config

- Add roots and list_roots_callback parameters to MCPClient.__init__,
  from_dict(), and from_config_file() methods
- Update create_connector_from_config() to pass roots params to all
  connector types (Stdio, HTTP, Sandbox)
- Allows clients to configure roots at the MCPClient level and have
  them propagate to all sessions

* test(python): add get_client_roots tool to primitive server

Add a tool that demonstrates the roots capability by requesting and
returning the list of roots from the connected client. Used for
integration testing of the roots feature.

* test(python): add integration tests for roots capability

Add comprehensive integration tests for the roots feature:
- test_roots_capability: Verify server can request/receive roots
- test_roots_empty_by_default: Verify empty roots when not provided
- test_roots_with_custom_callback: Verify custom callback precedence
- test_set_roots_updates_server_view: Verify dynamic root updates

* test(python): update unit tests for roots parameters

Update mock assertions in test_client.py to expect the new roots
and list_roots_callback parameters in create_connector_from_config
calls.

* ci(python): add roots to primitive tests and README badge

- Add roots to CI workflow primitive test matrix
- Add roots to PR comment report primitives list
- Add Roots badge to README Primitives row

* feat(docs): enhance MCP client and server documentation for roots feature

- Added `roots` and `list_roots_callback` parameters to MCP client initialization documentation.
- Updated `create_connector_from_config` documentation to include new parameters.
- Introduced `list_roots` method documentation in server context, detailing its usage and return values.
- Improved overall clarity and completeness of API reference for better developer guidance.

* feat(python): add get_client_roots tool to context example

- Introduced a new tool, `get_client_roots`, to the context example, demonstrating how to retrieve and display the list of roots exposed by the client.
- Updated documentation to include the new tool and its functionality, enhancing the example's coverage of context features.

* feat(docs): add roots documentation for client and server

- Introduced new documentation for the `roots` feature, detailing how clients can expose file system roots to MCP servers and how servers can access these roots.
- Added examples for configuring roots in the MCP client and using the `list_roots()` method in the server context.
- Enhanced overall clarity and usability of the documentation to support developers in implementing the roots functionality.

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: pietrozullo <pietro.zullo@gmail.com>
2026-01-12 11:16:09 +01:00
Vincenzo Reina aca5f9c040 feat(python): Adapt OAuth to 2.1 version from new MCP spec (#518)
* feat: Add PRM in the metadata discovery

* fix: fallback anyway to PRM

* feat: Implement complete discovery logic

* feat: Final implementation of CIMD

* feat: Implement PKCE

* feat: Add scope from WWW-Authenticate

* feat: Add all URLs possible styles

* feat: Update tests and example

* docs: Update docs

* fix: linting

* docs: update API documentation

* fix: correct typos in OAuth metadata and error messages

- Updated the comment in ProtectedResourceMetadata to use the correct abbreviation (PRM).
- Fixed a typo in the OAuthAuthenticationError message regarding code challenge support.
- Corrected the comment for legacy client paths to use "pre-registered" instead of "pre-reggistered".

* feat: restructure authentication documentation and add new methods

- Updated the authentication section in  to group authentication methods under a new Authentication category with an icon.
- Removed the old  file and replaced it with new documentation files for Bearer Token, Custom Auth, and OAuth 2.1.
- Introduced an overview page for authentication methods, detailing usage and configuration for each method.
- Enhanced security best practices and examples for each authentication type to improve clarity and usability.

* refactor: improve debug logging for OAuth metadata discovery

- Updated debug messages to provide clearer context by specifying the issuer or host being queried during OAuth and OpenID Connect metadata discovery.
- Enhanced error logging to remove redundant information, focusing on the failure reason without repeating the URL.

* fix: correct abbreviation in ProtectedResourceMetadata documentation

- Updated the abbreviation from PRC to PRM in the ProtectedResourceMetadata section to ensure accuracy in the documentation.

* fix(oauth): correct RFC 8414 well-known URL construction for path-based issuers

  The OAuth metadata discovery was incorrectly constructing .well-known URLs
  by appending to the issuer instead of inserting between host and path.

  RFC 8414 specifies that for an issuer like https://github.com/login/oauth,
  the .well-known URL should be:
    https://github.com/.well-known/oauth-authorization-server/login/oauth

  We were incorrectly building:
    https://github.com/login/oauth/.well-known/oauth-authorization-server

  This fix:
  - Implements correct RFC 8414 URL construction (insert between host/path)
  - Supports OpenID Connect style as fallback (append to issuer)
  - Removes GitHub-specific hardcode since discovery now works correctly
  - Adds documentation comments explaining the two standards

  Ref: https://www.rfc-editor.org/rfc/rfc8414.html#section-3

* chore: oauth examples

* docs: enhance OAuth endpoint discovery documentation

- Updated the OAuth documentation to clarify how `mcp-use` discovers OAuth endpoints using both OAuth 2.0 and OpenID Connect standards.
- Added a table detailing the URL construction methods for each standard.
- Included examples for better understanding and a note on fallback behavior when the issuer has no path.

* response to bs codeql

* fix: update API URL Updated the GitHub API URL in the configuration to the correct endpoint for OAuth operations.

---------

Co-authored-by: Enrico Toniato <2827496+tonxxd@users.noreply.github.com>
Co-authored-by: pietrozullo <pietro.zullo@gmail.com>
2026-01-11 18:09:34 +01:00
pietrozullo 36d754820f fix: remove links to redirect documentation in static files 2026-01-11 13:45:07 +01:00
Luigi Pederzani ff0233f73c feat(docs): add CLAUDE.md files for Python and TypeScript libraries (#775)
- Introduced CLAUDE.md files for both the Python and TypeScript implementations of the mcp-use framework, providing comprehensive guidance on project structure, testing standards, and development workflows.
- The root CLAUDE.md outlines critical workflows for non-trivial tasks, testing requirements, and documentation standards.
- Each language-specific file emphasizes the importance of tests, integration strategies, and post-implementation checklists to ensure code quality and maintainability.
2026-01-10 17:20:24 +01:00