Yiling-J 1b5cbf936a feat(mcp): add MCP server support with proxy tool and OAuth flow (#289)
* feat(mcp): add MCP server support with proxy tool and OAuth flow

Add URL-based MCP (Model Context Protocol) server support to the backend:

- DB: McpServer / AgentMcpServer / McpServerCredential models with
  typed JSON columns (auth config, cached tools, stored OAuth tokens,
  pending auth state) and a migration.
- Core (@shumai/core/src/mcp): DB-backed credential store, OAuth
  client provider (authorization_code + client_credentials) with a
  Hono-hosted redirect callback, connection lifecycle manager
  (Streamable HTTP with SSE fallback, lazy connect, 401 -> needs_auth),
  JSON Schema -> AgentTool parameter conversion, in-memory tool registry
  with ranked search, the single 'mcp' proxy AgentTool (search /
  describe / list / call / connect / status / auth-start), per-server
  opt-in direct tools ({server}_{tool}), and McpService (CRUD,
  discovery, OAuth, per-agent assignment via AgentMcpServer, and
  permission gating on tool execution mirroring skills).
- Agent: chat agents receive the 'mcp' proxy tool (plus direct tools
  for opted-in servers) built from their assigned, enabled servers.
- API: /teams/:teamId/mcp/servers CRUD, tools refresh/list, auth
  start/complete/status/remove, test, permission, and the public
  OAuth callback route; Admin authz via new ResourceType.McpServer;
  audit logging.
- DTOs: zod schemas + types for servers, tools, auth, and per-agent
  mcpServerIds.
- Tests: DB store, schema conversion, registry/search, service
  integration against a real in-process MCP server (v2
  @modelcontextprotocol/server), permission gating, rename
  invalidation, direct tools, per-agent assignment, API route tests,
  and workflow E2E (local + temporal) for proxy and direct modes.

* fix(mcp): persist OAuth discovery snapshot and stamp SEP-2352 issuer

The callback leg of the OAuth flow failed with
AuthorizationServerMismatchError ('discoveryState was not available on
the callback leg') because McpDbStore.savePendingAuth overwrote the
entire pendingAuth JSON column, clobbering the discoverySnapshot that
the provider's saveDiscoveryState() had stored inside it.

- McpDbStore.savePendingAuth now preserves an in-flight discovery
  snapshot so the callback leg can satisfy the SEP-2352 authorization-
  server issuer check.
- McpOauthProvider now round-trips the issuer stamp derived from the
  discovery snapshot: saveClientInformation/saveTokens persist it,
  clientInformation()/tokens() return it, and tokens() backfills a
  missing stamp for pre-existing credentials (removes the
  'stored OAuth credential has no issuer stamp' warning).
- Regression tests: savePendingAuth keeps the snapshot; the provider
  stamps/round-trips the issuer on both legs.

* fix(mcp): backfill SEP-2352 issuer stamp on stale OAuth client info

clientInformation() returned stored client info without an issuer field
when it had been dynamically registered before the stamping fix, so the
SDK logged 'stored OAuth credential has no issuer stamp' on every read.
Now the stored branch backfills the issuer from the discovery snapshot
(persisting it) exactly like the tokens() backfill.

* feat(webui): add MCP server configuration and agent assignment UI (#290)

* feat(webui): add MCP server configuration and agent assignment UI

* fix(webui): auto-detect auth for unconfigured MCP servers and show connect button

* fix(mcp): auto-generate state in mcp-oauth-provider when missing in DB

* fix(mcp): persist OAuth discovery snapshot and stamp SEP-2352 issuer

The callback leg of the OAuth flow failed with
AuthorizationServerMismatchError ('discoveryState was not available on
the callback leg') because McpDbStore.savePendingAuth overwrote the
entire pendingAuth JSON column, clobbering the discoverySnapshot that
the provider's saveDiscoveryState() had stored inside it.

- McpDbStore.savePendingAuth now preserves an in-flight discovery
  snapshot so the callback leg can satisfy the SEP-2352 authorization-
  server issuer check.
- McpOauthProvider now round-trips the issuer stamp derived from the
  discovery snapshot: saveClientInformation/saveTokens persist it,
  clientInformation()/tokens() return it, and tokens() backfills a
  missing stamp for pre-existing credentials (removes the
  'stored OAuth credential has no issuer stamp' warning).
- Regression tests: savePendingAuth keeps the snapshot; the provider
  stamps/round-trips the issuer on both legs.

* fix(mcp): backfill SEP-2352 issuer stamp on stale OAuth client info

clientInformation() returned stored client info without an issuer field
when it had been dynamically registered before the stamping fix, so the
SDK logged 'stored OAuth credential has no issuer stamp' on every read.
Now the stored branch backfills the issuer from the discovery snapshot
(persisting it) exactly like the tokens() backfill.

* fix(mcp): attach McpOauthProvider for auto-detected OAuth servers and discover tools on auth completion

* fix(webui): fix flex min-h-0 and max-h scrolling on MCP tools dialog

* fix(webui): set explicit flex height on McpToolsDialog for active scrolling

* feat(webui): make MCP server cards clickable to edit and widen server config dialog

* feat(mcp): agent-level server enablement and auto-detected server metadata (#291)

* feat(mcp): agent-level server enablement and auto-detected server metadata

- Remove the server-level `enabled` column from mcp_servers; enable/disable
  now happens per-agent via the AgentMcpServer join table (mirrors skills).
- Drop the unique (teamId, name) constraint so duplicate server names are allowed.
- Add a `description` column, auto-filled from client.getServerVersion() on
  connect; the server name is auto-filled from the reported title (fallback name)
  with a URL-derived placeholder until first connect.
- Remove manual name input: the create dialog is URL-only, and the edit dialog
  shows the auto-detected name/description read-only.
- Replace the include/exclude raw-text inputs with the tool list in the edit
  dialog, managing only excludeTools; remove includeTools support and the
  separate McpToolsDialog component.
- Sanitize server-reported names into safe direct-tool prefixes (spaces/punctuation
  become underscores) and use the same sanitization in the proxy resolver.

* fix(mcp): give the edit-dialog tool list a definite height

The Shadcn ScrollArea viewport is h-full, which requires a definite height
on the root. Using max-h-64 left the viewport at auto height, so the root
clipped the list at 256px without engaging its own scrollbar — tools past
the cutoff were unreachable. Use a fixed h-64 container (same pattern as
move-copy-dialog) so the inner scroll area scrolls independently of the
dialog's outer scroll.

* refactor(mcp): fixed header/footer with scrollable content in server config dialog

Mirror the skill config dialog layout: the edit dialog now keeps the header
and footer fixed and scrolls only the content area (ScrollArea flex-1
min-h-0 inside an h-[85vh] flex column). The tools list no longer has its
own nested ScrollArea — it flows inside the content-level scroll, so all
tools are reachable without a nested-scroll conflict. The create dialog
stays compact (URL-only) like the skill add dialog.

Verified headlessly that max-height-based ScrollArea roots do not engage
scrolling (viewport height resolves to auto), which is why the previous
nested list clipped; the flex-based definite-height pattern scrolls.

* feat(mcp): make the endpoint URL immutable after creation

Editing a server's URL effectively points it at a different server, and the
create flow is URL-only anyway — so the edit dialog no longer allows changing
it (delete + re-add covers endpoint changes). The URL is displayed read-only
next to the auto-detected name/description, and `url` was removed from the
update DTO and service; auth/transport changes still invalidate credentials
and cached tools.

* refactor(mcp): match MCP server cards to the skill card layout

The settings list cards now share the skill card structure: row 1 is the
server name (with direct-mode/transport badges) plus the three-dot menu,
row 2 is the description (falling back to 'No description provided') with
the endpoint URL and last error as small mono lines, and row 3 holds the
connection-status badge and updated date on the left with the permission
selector and the connect button at the right end.

* fix(mcp): stop card menu clicks from opening the edit dialog

The three-dot menu is portaled, so its item clicks bubble through React's
synthetic events to the card's onClick, which opened the edit dialog before
the delete confirmation appeared. Add e.stopPropagation() to every menu
item (matching the skill card pattern).

* fix(mcp): stop Refresh Tools from submitting/closing the config dialog

The Refresh Tools button lived inside the <form> and, like all buttons
without an explicit type, defaulted to type="submit" — clicking it ran the
form submit (save + close) instead of just refreshing. Set type="button".

Also per UX: while refreshing, the button is disabled with a spinning icon,
the per-tool enable/disable switches are disabled, and the success toast is
removed — the button reverting to its idle state is the success signal
(keep the error toast for failures).

* test(mcp): provide explicit redirectUri in McpOauthProvider test helper

* fix(mcp): scope tool registry to agent-assigned servers

The MCP tool registry was a process-global singleton keyed by server id,
so a chat agent could search, describe, and even call tools belonging to
MCP servers that were not assigned to it (e.g. disabled or unassigned
servers), as long as their metadata had been discovered at some point in
the process. This mirrors the disabled-skill bug: the read path never
checked per-agent enablement.

Replace the singleton with a fresh McpToolRegistry built per
buildAgentTools call and warmed from the persisted McpServer.tools DB
cache. Because the registry only ever contains the agent's assigned
servers, unassigned/disabled servers can neither be suggested, searched,
described, nor executed. Live discovery (lazy connect / connect action)
writes into the per-agent registry via ensureConnected(serverId,
registry?).

Adds test-first coverage: suggestions, search, describe and tool-call
leaks across an unassigned same-team server, staleness after
unassignment, and direct-tools scoping.

* feat(mcp): capture and surface server instructions + server-level refresh (#293)

* feat(mcp): capture and surface server instructions

- Add McpServer.instructions column, populated from getInstructions() at
  connect time (legacy initialize + modern discover results)
- Surface instructions at three levels like pi-mcp-adapter: truncated
  snippet in the mcp proxy tool description, preview in server listings,
  and full text via mcp({ instructions: "name" })
- Fix misleading mcp({ server, connect }) usage line to mcp({ connect })
- Share one renderServerListing helper across list and connect modes
- Expose instructions in McpServerInfo DTO and WebUI config card
- Test server supports instructions; service + API tests updated

* refactor(mcp): server-level refresh endpoint, drop agent connect mode

- Replace POST /mcp/servers/:id/tools/refresh with POST /mcp/servers/:id/refresh
  returning the refreshed McpServerInfo (server-level, not tools-level)
- Add McpService.refreshServer(): force-close the connection, re-discover and
  persist tools, instructions, name/description and status; used by the refresh
  endpoint, Test Connection, and post-OAuth completion (replacing discoverTools)
- Remove discoverTools entirely - refreshServer is the single discovery entry
  point (testServer and completeAuth route through it)
- Remove refreshTools from UpdateMcpServerRequest/PATCH (dead param)
- Remove mcp({ connect: "name" }) from the agent proxy tool: lazy tool calls
  still auto-connect, so agents are unaffected
- WebUI: remove the dialog 'Refresh Tools' button and create-mode background
  auto-refresh; add a server-level Refresh button at the left end of the edit
  dialog footer; i18n mcp_refresh_server (+ success message)

* feat(mcp): add in-flight request tracking and idle connection cleanup (#294)

* feat(mcp): add in-flight request tracking and idle connection cleanup

* feat(mcp): add background idle cleanup timer to McpService

* feat(mcp): update default background idle cleanup check interval to 30s

* feat(webui): improve MCP server card footer, instructions, and refresh dialog freeze (#295)

* feat(webui): improve MCP server list card, instructions dialog, and refresh freeze UI

* feat(webui): refine MCP card action menu items

* docs(webui): update direct tools mode description in i18n messages

* style(webui): refine Direct Tools Mode layout in MCP server config dialog

* feat(webui): remove tool search box from MCP server config dialog

* fix(mcp): make in-flight idle tracking test deterministic

The 'tracks in-flight requests and safely prunes idle connections' test
relied on a wall-clock sleep (10ms) to guess when the tool handler had
started executing on the server. On slow/loaded CI runners the HTTP round
trip through the real MCP client/server stack can exceed that window, so
resolveSlowTool() fired the no-op placeholder, the gated handler never
completed, and callPromise hung until the 5000ms test timeout.

The handler now signals via a deferred promise when it actually starts,
and the test awaits that signal (racing it against the call promise to
surface early failures) before asserting in-flight state and releasing
the gate. Also gives the test an explicit 10s timeout.
2026-08-11 11:01:38 +08:00
2026-08-09 20:58:35 +08:00
2026-08-09 14:49:07 +08:00
2026-08-01 21:38:42 +08:00
2026-05-19 16:05:09 +08:00
2026-06-09 20:00:46 +08:00
2026-08-09 20:58:35 +08:00

Shumai Logo

Shumai

An open-source platform for all your creative work.

Website | Docs | Demo | Discord | 中文

Shumai App Screenshot

Features

Shumai is an open-source Frame.io alternative built for creative teams to collaborate and share media with ease:

  • S3-Compatible & Local Storage: Store and serve creative assets securely using the local filesystem or any S3-compatible storage service, including AWS S3, Cloudflare R2, and MinIO.
  • Frame-by-Frame Annotations & Comments: Leave precise feedback with frame-specific drawing tools and timestamped comments on both video and image assets.
  • Secure Sharing & Collections: Create private share links and curated media collections for clients, stakeholders, and collaborators.
  • Granular Access Control: Manage workspace permissions with team-level and project-level role-based access control.
  • Distributed Transcoding via Temporal: Offload resource-intensive video transcoding to a background worker pool orchestrated by Temporal.
  • Custom Asset Metadata: Define dynamic metadata fields tailored to your production pipeline.
  • Share Link Watermarking: Protect shared media with customizable text and image watermarks, and save watermark as reusable templates.
  • Wide File Format Support: Preview common creative file formats, including images (with PSD support), videos, audio, and documents, while allowing any file type to be uploaded and stored.
  • Office & Document PDF Proxying via Gotenberg: Convert Word, PowerPoint, Excel, Markdown, HTML, and CSV documents to high-quality PDF proxies for in-browser previewing using Gotenberg.

But Shumai goes beyond being a Frame.io alternative. With modern models like GPT-Image-2 and Seedance 2.5, AI can already handle a surprising amount of creative work. That means you can create or update videos and images from a simple prompt without having to jump back into Photoshop, Premiere or Houdini. That is why Shumai includes a powerful agent system:

  • Agent as a Team Member: Mention a context-aware AI agent with @mentions directly in asset comments, just like a real teammate.
  • Agent as a One-to-One Assistant: Chat privately with the agent and ask it to help with tasks.
  • Custom Skills & Tools: Extend the agent by registering custom scripts, tools, and automation skills.
  • Isolated Sandbox Execution: Run agent-submitted scripts safely in a sandboxed environment.
  • AI Metadata Autofill: Automatically fill in custom metadata for new assets.
  • Semantic Search: Find assets by visual or conceptual meaning using vector embeddings (Gemini Embedding 2).

Here is a short demo video showing what the Shumai agent can do:

https://github.com/user-attachments/assets/1186067a-72c0-41b9-836f-987438f2332a

Note

Media Processing & Storage: When uploading media, Shumai always preserves and stores your original raw file. Note that the file size shown in the system represents the original file size and does not include the size of any transcoded files. For all media types (both images and videos), Shumai creates a 300p WebP poster image to serve as the preview in the file list view. Additionally:

  • For Images: Shumai generates a high-quality WebP proxy at the exact same resolution as your original file for optimized viewing.
  • For Videos: It generates at least one proxy video (depending on your transcoding settings), alongside a sprite image and a small preview video (capped at 1600 frames) to enable fast timeline scrubbing and lightning-quick previews.

Installation

Below is a quickstart guide for running Shumai with local storage. For advanced configuration options (including S3-compatible storage and Temporal workflow orchestration), see our Documentation.

Option 1: Docker Compose

Docker Compose is the fastest way to get Shumai running. You do not need to clone the repository or install packages manually. Ensure you have Docker and Docker Compose installed, then follow these steps:

  1. Create and navigate to a new directory for your configuration and data volumes:

    mkdir shumai && cd shumai
    
  2. Download the docker-compose.yaml file:

    curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose.yaml
    
  3. Configure environment variables (optional):

    • SHUMAI_SERVER_PORT controls the port the Shumai server listens on. The default is 3000.

    • By default, Shumai uses the bundled local storage service in this Docker Compose setup. To use an external S3-compatible storage instead, configure the environment variables for your S3 provider. Here are examples for AWS S3 and Cloudflare R2:

      AWS S3 Example:

      STORAGE_BACKEND: s3
      S3_BUCKET: your-bucket-name
      S3_ACCESS_KEY_ID: your-access-key-id
      S3_SECRET_ACCESS_KEY: your-secret-access-key
      AWS_ENDPOINT_URL_S3: https://s3.us-east-1.amazonaws.com
      

      Cloudflare R2 Example:

      STORAGE_BACKEND: s3
      S3_BUCKET: your-bucket-name
      S3_REGION: auto
      S3_ACCESS_KEY_ID: your-access-key-id
      S3_SECRET_ACCESS_KEY: your-secret-access-key
      AWS_ENDPOINT_URL_S3: https://<account-id>.r2.cloudflarestorage.com
      
    • By default, AWS_ENDPOINT_URL_S3 is set to: http://localhost:{SHUMAI_SERVER_PORT}, if you use local storage and expose Shumai on a custom host/port combination, set AWS_ENDPOINT_URL_S3 to the external URL that browsers will use to upload files.

      For example, if you change the port mapping in docker-compose.yaml from 3000:3000 to 12345:3000 and deploy on a server with IP address 12.34.56.78, set:

      AWS_ENDPOINT_URL_S3: http://12.34.56.78:12345
      

      This value must be reachable from client browsers and should include the externally exposed port.

  4. Start the services in detached mode:

    docker compose up -d
    
  5. Open your browser and access Shumai at http://localhost:3000 (or http://<your-server-ip>:3000 for remote deployments).

Option 2: Install via NPM / Package Manager

Shumai is published as @shumai-one/shumai on NPM. This option allows you to run Shumai globally or locally.

Step 1: Start PostgreSQL with pgvector

Shumai requires PostgreSQL with the pgvector extension. Start a pre-configured database container using Docker:

docker run --name shumai_postgres \
  -e POSTGRES_USER=shumai \
  -e POSTGRES_PASSWORD=shumai_password \
  -e POSTGRES_DB=shumai_db \
  -p 5432:5432 \
  -d pgvector/pgvector:pg18

Step 2: Create a workspace folder

Create a dedicated directory to store your environment configuration and media files (which are saved in a ./data directory by default):

mkdir shumai && cd shumai

Step 3: Install Platform-Specific Dependencies

Linux

Shumai requires the following system packages on Linux:

  • ffmpeg – Used for media transcoding and metadata extraction.
  • poppler (poppler-utils) – Used for PDF page image extraction and PDF sprite preview generation (pdftoppm).
  • imagemagick – Used for PSD format transcoding and color profile conversion to sRGB.
  • bubblewrap, socat, and ripgrep – Required by the AI agent sandbox (anthropic-experimental/sandbox-runtime) for process isolation, networking, and workspace search.

Install all required packages with one command:

Ubuntu/Debian

sudo apt install -y ffmpeg poppler-utils imagemagick bubblewrap socat ripgrep

Fedora

sudo dnf install -y ffmpeg poppler-utils ImageMagick bubblewrap socat ripgrep

Arch Linux

sudo pacman -S --noconfirm ffmpeg poppler imagemagick bubblewrap socat ripgrep

Note

Ubuntu 24.04+ restricts unprivileged user namespaces by default. This prevents anthropic-experimental/sandbox-runtime from using bubblewrap for sandbox isolation.

To temporarily allow user namespaces:

sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0

Alternatively, configure an AppArmor profile that grants the required userns permission to the relevant binaries.


macOS

Shumai requires:

  • ffmpeg – Used for media transcoding and metadata extraction.
  • poppler – Used for PDF page image extraction and PDF sprite preview generation (pdftoppm).
  • imagemagick – Used for PSD format transcoding and color profile conversion to sRGB.
  • ripgrep – Required by the AI agent sandbox (anthropic-experimental/sandbox-runtime).

Install the required packages with Homebrew:

brew install ffmpeg poppler imagemagick ripgrep

Windows (alpha)

Warning

Windows support in anthropic-experimental/sandbox-runtime is alpha and the design is in flux.

The current implementation provides:

  • Network egress filtering via the Windows Filtering Platform (WFP).
  • File read/write denial via ACL stamping.

However, it is not a security boundary against a deliberately adversarial sandboxed process.

The sandbox implementation will be substantially revised in a future release, where sandboxed processes will run under a dedicated sandbox user account.

Shumai requires:

  • ffmpeg – Used for media transcoding and metadata extraction.
  • imagemagick – Used for PSD format transcoding and color profile conversion to sRGB.

Install required packages using your preferred package manager:

winget

winget install Gyan.FFmpeg ImageMagick.ImageMagick

Chocolatey

choco install ffmpeg imagemagick

Step 4: Install Shumai globally

Install Shumai globally using your preferred package manager:

# NPM
npm install -g @shumai-one/shumai

# PNPM
pnpm add -g @shumai-one/shumai

# Bun
bun add -g @shumai-one/shumai

Step 5: Configure Environment Variables

Create a .env file in your workspace folder (shumai/) and add the following configuration:

DATABASE_URL=postgresql://shumai:shumai_password@localhost:5432/shumai_db?schema=public
BETTER_AUTH_SECRET=ySxs7DxzHDZBbeeHNPEwBuspYwipBqz5Gk5XdBjNhWw=
STORAGE_BACKEND=local
SHUMAI_SERVER_PORT=3000
AWS_ENDPOINT_URL_S3=http://localhost:3000
# Optional: base URL for MCP OAuth redirects (defaults to BETTER_AUTH_URL)
MCP_OAUTH_REDIRECT_BASE_URL=http://localhost:3000

Note

SHUMAI_SERVER_PORT sets the port the server starts on, while AWS_ENDPOINT_URL_S3 is used by the browser to build file upload URLs. If deploying on a remote server (e.g. http://123.456.7.8) with a mapped port (e.g. 12345:3000 in docker-compose), set AWS_ENDPOINT_URL_S3 to http://123.456.7.8:12345. MCP_OAUTH_REDIRECT_BASE_URL is only needed when MCP servers use OAuth: the authorization redirect URI defaults to {BETTER_AUTH_URL}/api/mcp/oauth/callback; set it to an externally reachable URL if the app is served behind a proxy.

Step 6: Run Shumai

Important

For Bun Users: Since the published package binaries contain a #!/usr/bin/env node shebang, running the global command directly (e.g., shumai) will execute under Node.js. If you installed with Bun and want to run under the Bun runtime, you must prefix all commands with bun run --bun (e.g., bun run --bun shumai, bun run --bun shumai -d, bun run --bun shumai stop).

Start the application from your workspace folder:

shumai

Alternatively, you can run and manage Shumai in daemon mode:

  • Start in daemon mode:
    shumai -d
    
  • Stop Shumai:
    shumai stop
    
  • Restart Shumai:
    shumai restart
    
  • Show/tail logs:
    shumai logs
    

On startup, Shumai will automatically run database migrations and start the web server at http://localhost:3000.


Option 3: Run from Source (Development)

To set up Shumai locally for development:

  1. Clone the repository and install dependencies:
    git clone https://github.com/shumaiOne/shumai.git
    cd shumai
    bun install
    
  2. Start the pgvector database container (as described in Option 2, Step 1).
  3. Create a .env file at the root of the workspace using the configuration from Option 2, Step 5.
  4. Apply the database schema migrations:
    bun run db:migrate
    
  5. Start the local development server:
    bun run dev
    

Command Line Interface (CLI)

Shumai provides a Command Line Interface (CLI) tool to manage projects, folders, and assets, upload files/folders, and create new versions directly from your terminal.

For more details on installation and usage, see the CLI Readme.

Languages
TypeScript 82.2%
JavaScript 17%
CSS 0.5%
PLpgSQL 0.2%