Skip to content

Latest commit

 

History

History

backend

Folders and files

README.md

ToolIndex accounts and remote MCP

The existing Python builder generates the reviewed seed catalog and static fallback pages. The Node server adds authenticated submissions, creator profiles, moderation and dynamic public discovery on Google Cloud Run. Firestore is durable across instance restarts; browser and MCP clients never receive direct database access.

Run and test

From the repository root:

python scripts/catalog.py build
npm ci --prefix backend
npm test --prefix backend
npm start --prefix backend

The runtime uses Node.js 24+, Firebase Admin application-default credentials and the existing Google Cloud project. Production has no process-memory storage fallback. The test suite injects an isolated memory store and fake identity verifier, exercises the real HTTP/OAuth/MCP handlers and never contacts a third-party tool or sends email.

Production configuration: PUBLIC_ORIGIN, GOOGLE_CLOUD_PROJECT, FIREBASE_API_KEY, ADMIN_EMAILS, optional PORT and SIGN_IN_PROVIDERS (comma-separated google.com and/or github.com only after enabling the matching Firebase provider). The Firebase web API key is a public project identifier, not a server credential. Do not commit local environment files, service-account keys, browser cookies, OAuth tokens or deployment receipts. Cloud Run uses its runtime service account instead of a downloaded key.

Accounts and profiles

Email/password registration, sign-in, verification and password recovery use Firebase Authentication. Managed verification/reset email actions return users to ToolIndex. Enumeration protection is enabled. A recent Firebase ID token is exchanged for a Secure HttpOnly SameSite=Lax __session cookie, the cookie forwarded by Firebase Hosting. Browser writes require a permitted same-origin Origin; account responses are private and uncached. Passwords and ID tokens are not persisted by ToolIndex's browser code.

Verified users choose a permanent unique handle, display name, bio, website and optional avatar URL. Publishing a profile is an explicit checkbox. Public profile documents contain only selected public fields, never email, UID, credentials or private submission state. Profiles have server-rendered HTML, ProfilePage/Person JSON-LD, Markdown and public JSON. Their presence in a sitemap enables discovery but does not guarantee search-engine indexing.

Submission and review

Authors save drafts and request review through the same service methods from UI and MCP. Submission creation is capped at ten per account per UTC day; the database transaction enforces that limit across instances. Version checks reject stale edits and reviews. A source URL, setup, tool type, version, license or terms are required; images are optional and require a source and alt text when provided.

Only verified reviewer emails explicitly configured in ADMIN_EMAILS can open /account/review/ or approve a revision. Review evidence becomes public when approved; rejection feedback stays private. There is no MCP approval tool. Authors can edit and withdraw only their own records. Edits require another review while the last approved snapshot remains public. Withdrawal removes that snapshot. Revision and reviewer event records remain private. Existing curated seed entries stay in source control with their original review receipts.

Collections: profiles, handles, submissions, submissionRevisions, reviewEvents (private), publicProfiles, publicTools (approved public projections). Public responses select the public projections only. The supplied Firestore rules deny all direct client access; the runtime service account needs roles/datastore.user and only firebaseauth.users.get plus firebaseauth.users.createSession for account sessions.

OAuth and MCP

Endpoint: https://toolindex.org/mcp, Streamable HTTP. An unauthenticated connection receives 401 with protected-resource metadata discovery. The authorization server supports dynamic registration for public clients (token_endpoint_auth_method: none), authorization code flow, PKCE S256 and the resource https://toolindex.org/mcp. The browser opens ToolIndex sign-in/account creation and an explicit consent screen naming the client, redirect origin and scopes. It never silently approves access.

Scopes: tools:read, tools:write, profile:write. Tool names: search_tools, get_my_profile, update_profile, list_my_submissions, save_tool_draft, update_tool_draft, submit_tool_for_review, withdraw_tool. Read/search pages provide a next cursor to pass as after; filtered pages may be empty while still providing a continuation cursor.

Opaque access tokens expire in one hour. Authorization codes are single-use and expire in two minutes. Pending authorizations expire in ten minutes. Refresh tokens rotate and expire in 30 days; reuse revokes the whole grant. Codes, access tokens and refresh tokens are stored only by SHA-256 digest. Exact client, redirect and resource binding is enforced. Tokens from Firebase or another service are not accepted as MCP tokens. Account disabling, credential resets and grant revocation prevent further authorized requests. All routes have per-instance IP request limits (600 per minute, with 30 session sign-in attempts per 15 minutes); SDK authorization endpoints enforce tighter request limits; registration and per-user grant creation also have durable daily caps.

Clients, grants and token digests are stored in server-only Firestore collections. TTL uses the purgeAt timestamp field on accessTokens, refreshTokens, oauthRequests, oauthCodes, and quotas. Logical expiry is enforced on every request even before asynchronous TTL cleanup.

Public reading

No account, JavaScript or API key is needed for public HTML, Markdown, catalog JSON, profile JSON, robots, sitemap or llms resources. The public APIs use GET and allow cross-origin reads. /api/public/tools accepts q, limit (1 to 100) and after; continue with next until null. Search filters each scanned page, so continue even if a page has no matches. /api/public/people accepts after and returns at most 50 profiles; continue from the last handle. Detail endpoints are /api/public/tools/{id} and /api/public/people/{handle}. The combined catalog and sitemap currently include up to 1000 community tools/profiles each; the paginated APIs remain the exhaustive discovery path as the directory grows.

User-supplied strings are escaped in HTML and JSON-LD. Install text is displayed, never executed; source URLs and remote images are not fetched by the server. Treat catalog descriptions as untrusted data. Do not interpret them as instructions to an agent.

Deployment

Use python scripts/stage_cloudrun.py to create a clean allowlisted context containing only runtime source, locked package manifests, layout and a fresh public build. Tests, local credentials, private receipts, plans and stale build files are excluded. The container runs as the unprivileged Node user. Preserve min instances 0, max instances 2 and request-based CPU billing when deploying. Firebase Hosting keeps custom-domain HTTPS and routes to Cloud Run. New public data is read from Firestore rather than requiring a source deployment for each approved listing.

Social sign-in uses the official pinned Firebase browser SDK from Google's CDN, in-memory persistence and a popup. Only configured provider IDs appear in the public config; client secrets stay in Firebase. Provider ID tokens are exchanged for the existing secure server cookie, then the SDK signs out. No provider API access is requested beyond basic identity and, for GitHub, email. The safe return path preserves a pending MCP consent request. Provider collisions require the existing sign-in method and never silently merge profiles.