Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/quiet-public-mcp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@transloadit/mcp-server": minor
"@transloadit/node": patch
"transloadit": patch
---

Add an opt-in public HTTP endpoint for Robot lookups and Assembly Instructions linting. Embedders can enable first-party documentation search separately. The public endpoint requires a rate-limit hook and preserves the authenticated endpoint’s OAuth flow.

The Node SDK linter can cap serialized diagnostics while computing the verdict from all issues.
12 changes: 11 additions & 1 deletion packages/mcp-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,20 @@ Allowlist tools in `~/.gemini/settings.json`:
- `npx -y @transloadit/mcp-server http --endpoint https://api2.transloadit.com`
- `npx -y @transloadit/mcp-server http --config path/to/config.json`

The JSON config accepts the same keys as `createTransloaditMcpHttpHandler()`, including
The JSON config accepts options including
`allowedOrigins`, `resourceMetadataUrl`, `signatureAlgorithm`, `resultDomains`, `widgetDomain` and
`consoleUrl`.

### Public HTTP endpoint for embedders

Pass `publicPath: '/mcp/public'` to `createTransloaditMcpHttpHandler()` to add a keyless path next to the existing MCP endpoint. Route only the public path from your host, or protect the existing path with a static `mcpToken` or a token-validating gateway. With `resourceMetadataUrl` alone, the Node handler checks for a bearer value. API2 validates that value when tools make account calls. If your OAuth deployment relies on the separate public quotas, verify bearer tokens at the gateway before forwarding requests to `/mcp`.

`publicPath` requires a `checkPublicRateLimit(request, signal)` callback. It receives request headers and the socket's `remoteAddress` before the handler reads the body. Use forwarded IP headers only from trusted proxies. Return `null` to admit a POST or a positive safe integer in seconds to send HTTP 429. Honor the signal when a client disconnects, the handler shuts down, or the two-second check deadline expires. Failed or timed-out checks return HTTP 503.

The public endpoint defaults to Robot list, Robot help, and Assembly Instructions lint. These tools run locally with zero outbound HTTP. Set `publicDocsSearch: true` to add docs search against the fixed first-party Transloadit URL. Search has ten shared upstream slots. Apply a per-caller budget that leaves capacity for other callers.

The public endpoint caps request bodies at 128 KiB, rejects batches, and serves its discovery card at `/mcp/public/.well-known/mcp/server-card.json`. Both routes use wildcard CORS by default and honor an explicit `allowedOrigins` list. Set the Node HTTP server's `requestTimeout` to bound the time clients have to send a body after admission. Public lint fixes accept simple Instructions of at most 8 KiB. Lint results set `linting_issues_truncated` when diagnostics exceed the 32 KiB budget.

## Tool surface

| Tool | Account | OAuth scopes | Notes |
Expand Down
42 changes: 42 additions & 0 deletions packages/mcp-server/src/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,48 @@ export async function searchTransloaditDocs(
return docsSearchResponseSchema.parse(body).results
}

const publicSearchCache = new Map<string, { expiresAt: number; results: DocsSearchResult[] }>()
const publicSearchInFlight = new Map<string, Promise<DocsSearchResult[]>>()

/** Bound outbound search work across the stateless public server instances. */
export async function searchPublicTransloaditDocs(
query: string,
section: string | undefined,
limit: number,
): Promise<DocsSearchResult[]> {
const key = JSON.stringify([query, section, limit])
const cached = publicSearchCache.get(key)
publicSearchCache.delete(key)
if (cached && cached.expiresAt > Date.now()) {
publicSearchCache.set(key, cached)
return cached.results
}

const pending = publicSearchInFlight.get(key)
if (pending) return pending
if (publicSearchInFlight.size >= 10) {
throw new DocsError(
'mcp_docs_unavailable',
'Documentation search is busy. Try again shortly.',
'public_search_busy',
)
}

// The shared request uses the upstream deadline so one caller's departure cannot cancel it
// for the other callers waiting for the same results.
const request = searchTransloaditDocs(query, section, limit)
publicSearchInFlight.set(key, request)
try {
const results = await request
const oldest = publicSearchCache.keys().next().value
if (publicSearchCache.size >= 500 && oldest !== undefined) publicSearchCache.delete(oldest)
publicSearchCache.set(key, { expiresAt: Date.now() + 5 * 60_000, results })
return results
} finally {
publicSearchInFlight.delete(key)
}
}

/** Fetch a bounded page of Markdown. Pagination offsets count Unicode code points. */
export async function getTransloaditDoc(
pathOrUrl: string,
Expand Down
10 changes: 7 additions & 3 deletions packages/mcp-server/src/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ import { createRequestTransport } from './request-transport.ts'
import { createTransloaditMcpServer } from './server.ts'
import { buildServerCard, serverCardPath } from './server-card.ts'

export type TransloaditMcpExpressOptions = TransloaditMcpHttpOptions & {
path?: string
}
export type TransloaditMcpExpressOptions = Omit<
TransloaditMcpHttpOptions,
'publicPath' | 'publicDocsSearch' | 'publicMaxRequestBodyBytes' | 'checkPublicRateLimit'
>

export function createTransloaditMcpExpressRouter(options: TransloaditMcpExpressOptions = {}) {
if ('publicPath' in options && options.publicPath !== undefined) {
throw new Error('publicPath requires the Node HTTP handler.')
}
assertHttpOptions(options)
const router = express.Router()
const routePath = options.path ?? '/mcp'
Expand Down
Loading
Loading