18 Commits

Author SHA1 Message Date
Rahul selvaraj
5ea8fa1ebc fix(mcp): let operators declare Fake-IP ranges for self-service servers (#2857)
* fix(mcp): let operators declare Fake-IP ranges for self-service servers

A local proxy in Fake-IP mode (Loon, Clash, Surge) answers DNS for public
hostnames with synthetic private addresses, e.g. fd27:712::/32 from Loon,
and routes the connection by hostname. Strict validation then rejects
public MCP Store entries such as GitMCP as private-network targets.

Add DEEPTUTOR_MCP_FAKE_IP_RANGES (comma separated CIDRs, opt-in, read from
the process environment). In strict mode an address a hostname resolves to
inside a declared range is no longer rejected as private. IP-literal URLs,
loopback and the link-local/metadata ranges stay blocked regardless, and
any other private answer for the same host still fails validation.

Closes #2789

Assisted-by: Claude <noreply@anthropic.com>

* fix(mcp): warn on Fake-IP opt-in and document single-user SSRF trade-offs

Address review feedback from JinhangHE126 on #2857:
Document clearly that DEEPTUTOR_MCP_FAKE_IP_RANGES relaxes hostname-based SSRF protection for hostnames resolving into declared ranges (as the proxy resolves targets and connects).
Emit a startup security warning when DEEPTUTOR_MCP_FAKE_IP_RANGES is set, noting that the setting is intended strictly for single-user/desktop installations.

Assisted-by: Gemini (Google Vertex AI)
2026-12-01 10:32:50 +08:00
zszz3
12e9809a6e fix: reach loaded tools through call_tool instead of growing tools[] mid-turn
load_tools appended the loaded schema to the end of tools[]. tools[] is the
first thing in the provider's prompt-cache key, so the next request of the
same turn re-processed the system prompt and the whole history.

When the turn mounts the new call_tool builtin, load_tools now returns the
loaded tools' definitions in its result and leaves tools[] alone; the loop
forwards each call_tool call to the named tool before dispatch, so the tool
runs with its own argument checks, injected kwargs and trace, while the
history keeps the model's own call. Tools loaded this way stay proxied for
the session (loaded_tools.json gains proxied_tools). Runtime loads that must
land in tools[] pass native=True; the TypeScript engine keeps the old
behaviour.
2026-11-30 23:35:59 +08:00
Bingxi Zhao (Frank)
b46d9b5763 fix(mcp): reconnect after consent and refresh authorization status
Local dev repairs for #2586.

OAuth owner isolation and refresh-token stability verified. Hook polls until connected, refreshes on focus and stops on unmount. Python rechecks: 56 passed; UI batch: 25 passed. Web typecheck, 1407 Node tests, eslint and i18n passed.
2026-11-15 00:50:30 +08:00
Bingxi Zhao (Frank)
49d727f32d Merge PR #2492: fix(mcp): refresh persisted OAuth grants after restart 2026-11-14 22:57:41 +08:00
evan188199-tech
585d7656c7 fix(mcp): pass the server name into the OAuth store during Test (#2587)
POST /api/space/mcp/servers/{name}/test discarded the path name, so a
probe of an OAuth-backed server built its token store with '' and every
Test answered "ValueError: Unsafe MCP server name for an OAuth store: ''"
— including for a server that was authorized and connected.

probe_server now takes a server_name (the name the saved connection
would address the grant under) and the space router passes the path
name for OAuth configs. A scratch name no grant could live under (an
unnamed draft) is answered the way an unauthorized server is instead of
the store's refusal; non-OAuth probes stay nameless as before.

Fixes #2587

Signed-off-by: evan188199-tech <238371241+evan188199-tech@users.noreply.github.com>
2026-11-10 15:35:07 +08:00
iSanae233
cca82c0cca test(mcp): cover SDK discovery redirect contracts
Exercise same-origin metadata redirects and cross-origin redirect rejection
through the SDK's public HTTPX auth interface. Document why the discovery
extension uses the inner generator to retain SDK redirect handling.

Co-Authored-By: GPT-6 Astra
2026-11-09 00:22:57 +08:00
iSanae233
5b328be253 fix(mcp): preserve SDK issuer provenance after authorization
Remove the successful-exchange issuer stamp so resource-origin fallback
grants cannot be rebound to a different PRM-advertised authorization server.
Keep unbound grants subject to renewed authorization before refresh.

Add offline HTTPX regression coverage for cross-origin fallback across
restart and metadata changes, same-origin unbound grants, and verified
cross-origin refresh.

Co-Authored-By: GPT-6 Astra
2026-11-08 22:57:43 +08:00
iSanae233
0bbbe24779 fix(mcp): refresh persisted OAuth grants after restart
Persist and restore token expiry across runtime restarts. Discover the
protected resource and bound authorization server before refreshing saved
grants, preserve issuer bindings, and retain SDK discovery fallbacks.

Require MCP 1.30 in module and packaging metadata, and update the existing
dependency-floor assertion.

Co-Authored-By: GPT-6.1 Sol High
2026-11-06 17:34:54 +08:00
Bingxi Zhao (Frank)
1e7eef0e9a feat(research): add grounded scientific primitives and scoped private MCP origins (#1629) 2026-10-08 10:05:38 +08:00
Bingxi Zhao (Frank)
fc39543bc0 feat: integrate frontend backend and canonical routes 2026-09-01 22:24:29 +08:00
Bukely_
07abbd7326 feat(pageindex): add OSS knowledge bases and reasoning-based retrieval (#907)
Adds PageIndex OSS as a knowledge-base type and moves PageIndex retrieval from traditional RAG to reasoning-based retrieval: a small workflow-owned agent loop reads the document tree instead of going through the built-in MCP server, which this removes.
2026-08-20 00:35:15 +08:00
NoxsMedia
d388b697c5 fix(mcp): omit image payloads from tool text (#848) 2026-08-16 19:08:12 +08:00
Souptik Chakraborty
1091a88fc4 fix: Install mcp by default so pageindex MCP connects (#852)
The `mcp` client was declared only under the `partners` extra, but the MCP
connection manager and the built-in PageIndex MCP server are core: the manager
overlays a reserved `pageindex` entry onto the config whenever a PageIndex API
key is set, on any turn. A plain `pip install deeptutor` therefore had no `mcp`,
so the connection task raised ModuleNotFoundError, never resolved the caller's
ready future, and every turn stalled for the full 15s connect timeout before
reporting the one cause that was not responsible: "connect timed out after 15s".

Declare `mcp>=1.26.0,<2.0.0` as a core dependency of both published
distributions and drop it from the `partners` extra, which now inherits it.
Mirror the move in requirements/ (cli.txt gains it, partners.txt inherits it
via server.txt).

Also import `mcp` inside `_run_server`'s guarded block rather than above it. At
function scope the import raised before anything could fail `ready`, which is
what turned a permanent, instantly-knowable error into a timeout plus an
orphaned "Task exception was never retrieved". Inside the block the real cause
reaches the caller immediately.

Closes #792
2026-08-16 19:07:59 +08:00
khunmax2
da6038b379 fix(mcp): reconnect on credential change; stop reporting transport failures as tool timeouts (#813)
* update

* fix(mcp): reconnect on credential change; stop masking transport errors as timeouts

Two independent bugs, both surfaced connecting a remote MCP server that
authenticates with a header key.

connection_signature() fingerprints the stored config, which holds
${secret:...} references rather than values, so rotating a credential left
the reload diff byte-identical and the session kept using the replaced key
until the process restarted. _signature() now mixes in a digest of the
materialized config. The digest, never the value, reaches the signature;
configs with no references keep their plain signature, so this does not
invalidate and drop every live session on upgrade.

A transport failure on the POST carrying a tool call is raised inside the
SDK's own anyio task group and never resolves the caller's request, so a
call that failed in under a second was reported as a tool timeout -- the
one explanation that rules out the actual cause. call_tool() now watches
the connection task alongside the call and reports the error that task
recorded. _run_server() routes its post-live failure through the existing
describe_connect_failure(), so that string names the HTTP status rather
than "unhandled errors in a TaskGroup".

Tests: tests/services/mcp/test_call_failures.py

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

* docs: add Open Source Partners section with PageIndex

* docs: replace partner blurb with PageIndex promo code

* docs: link PageIndex subscription to developer portal

* docs: point PageIndex logo at its GitHub repo

* fix: harden Responses stream parsing (#825)

* fix: remove obsolete Typer extra (#817)

* fix: normalize RAG citation payloads (#808)

* fix: decouple mastery paths from chat sessions (#810)

* fix(llm): mark OpenAI Codex as vision capable (#821)

Declare the Codex Responses provider as image-capable so multimodal calls do not silently degrade to text and RAG image indexing can use it. Cover capability resolution, fallback behavior, and input_image conversion.

* fix: return minimal reasoning_effort for Gemini 3 and 2.5 Pro (#809)

Gemini 3 models and Gemini 2.5 Pro reject reasoning_effort="none"
with a 400 INVALID_ARGUMENT error. Per Google's OpenAI-compat docs,
"none" is only valid for the 2.5 Flash family.

Return "minimal" (the lowest valid level) for Gemini 3 and 2.5 Pro,
preserving the cost-intent while avoiding the API error.

Fixes #734

Co-authored-by: 0xtidalbore <ahmed@itcloud.ca>

* fix(mcp): don't orphan a cancelled call, or leak a URL credential

Follow-ups to this branch's own two fixes, both on paths it opened:

- ``asyncio.wait`` — unlike ``gather`` — leaves the futures it waits on
  running when the *waiter* is cancelled, and the call was moved into a
  free-standing task, so nothing else would ever stop it. Stopping a turn
  left the tool running against the server with its result discarded.
  Cancel and absorb it whenever the wait is interrupted, sharing one
  ``_abandon`` helper with the connection-died path.
- A dead transport is now reported to the *model*, not just in settings,
  and httpx names the full request URL in its message. ``CredentialTarget``
  includes "url_param" and several curated servers use it, so that string
  can carry an API key. Redact query and userinfo before it travels.

Also: route the one transient retry through the same watcher (a retry is
if anything more likely to meet a dead transport — the exact failure this
branch exists to stop reporting as a timeout), and skip materializing a
config that holds no ``${secret:...}`` references at all. The latter is
worth it: ``_signature`` runs per live connection on every reload, which
``ensure_scope`` performs once per turn, and resolving does per-reference
mkdir + chmod + read synchronously on that path.

---------

Co-authored-by: Bingxi Zhao (Frank) <13051345080@163.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: NoxsMedia <155662416+NoxsMedia@users.noreply.github.com>
Co-authored-by: 0xTidalBore <142905837+0xTidalBore@users.noreply.github.com>
Co-authored-by: 0xtidalbore <ahmed@itcloud.ca>
2026-08-12 17:06:37 +08:00
Bingxi Zhao (Frank)
740ec413a0 release: v1.5.7
Per-account MCP Services and CLI Apps — the two ways a deployment plugs in
tools DeepTutor never shipped — plus the isolation that makes them safe on a
shared install.

- MCP Services: a 45-entry curated store of hosted servers each account
  installs for itself, OAuth 2.1 (PKCE + dynamic client registration) for the
  servers that require it, static keys held by reference and resolved in memory
  at connect time, stdio refused for self-service. Settings no longer
  configures MCP; /settings/mcp redirects to the store.
- CLI Apps: 101 tools snapshotted from the two CLI-Anything registries.
  Installs are admin-only, the registry's install_cmd is parsed into an argv we
  build rather than executed, npm install scripts are forced off, and 66
  first-party entries are pinned to one reviewed commit. Apps land in
  data/cli-apps, one environment each, mounted read-only into the runner.
- Credentials that authorise a person move to data/system, the one branch the
  exec sandbox never mounts: Codex tokens relocate themselves on first use
  (refusing to follow a symlink), per-user MCP configs and keys land beside
  them.
- Grants gain a cli_apps whitelist with the same deny-by-default posture as
  MCP tools; a per-turn registry view keeps one owner's provider tools out of
  the process-global registry and refuses an unauthorised tool at execute, not
  just in the manifest.
- The composer reports what filled this turn's context window, a gutter rail
  jumps back through long conversations, and the workspace collapses to a
  drawer on small screens.
- The composer keeps focus after sending and across tab switches (#720);
  released images carry provenance and SBOM attestations (#722).

README prose, all ten translated READMEs, and the docs-site pages that named
Settings → MCP are updated to match. Release notes:
assets/releases/ver1-5-7.md
2026-07-31 00:25:48 +08:00
BukeLy
3288ce7931 refactor(pageindex): trim review findings — drop redundant dir resolution in search, dedupe deferred_tools() call, inline blocklist, fix stale docstrings 2026-07-15 18:30:04 +08:00
BukeLy
2e82ad4d27 feat(pageindex): agentic retrieval via MCP tools + full document-endpoint format support
PageIndex deprecated its REST retrieval endpoint; deep retrieval is now
agentic through the hosted PageIndex MCP server, while search() serves
programmatic callers with real document tree outlines.

- New built-in "pageindex" MCP server entry, code-injected at manager load
  when an API key is configured (never persisted to mcp.json; user-defined
  entry wins; hot-reloads on key change). remove_document is blocked via a
  new MCPServerConfig.disabled_tools blocklist.
- Chat turns with a PageIndex KB attached get the server's tools preloaded
  under a narrowed implicit grant (KB access = permission), plus a system
  prompt block listing the KB's file -> doc_id manifest with usage notes.
  The rag tool's kb_name enum excludes PageIndex KBs (a pure-PageIndex
  conversation doesn't mount rag), so the agent reads those docs via MCP.
- PageIndexPipeline.search() now returns each document's tree outline
  (titles / pages / summaries) fetched over REST (GET /doc/{id}/?summary=true)
  as honest structural context for programmatic callers (book, co-writer,
  seed, CLI). No new error_type; existing not_configured / retrieval_error /
  needs_reindex semantics are unchanged. The dead REST retrieval client
  methods are deleted. Existing KBs need no migration.
- SUPPORTED_EXTENSIONS now mirrors POST /doc/: pdf, md, markdown, txt, docx,
  doc, pptx, ppt, xlsx, xls, csv (zip stays a local container); frontend
  format list + copy updated (en/zh).
2026-07-15 18:21:43 +08:00
Bingxi Zhao (Frank)
46093e5e2b update msg 2026-06-11 20:03:34 +08:00