Skip to content

feat(api): add v2 endpoints for MCP servers, skills, custom tools, folders, and credentials - #6150

Merged
TheodoreSpeaks merged 6 commits into
v2-api-specfrom
feat/v2-resource-endpoints
Aug 1, 2026
Merged

feat(api): add v2 endpoints for MCP servers, skills, custom tools, folders, and credentials#6150
TheodoreSpeaks merged 6 commits into
v2-api-specfrom
feat/v2-resource-endpoints

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • Adds full CRUD to the public v2 API for five resources that had no public surface at all: MCP servers, skills, custom tools, folders, credentials (25 endpoints). Provisioning a workspace by API no longer has to stop and use the UI.
  • Secret material is write-only on read. MCP request headers return as hasHeaders + headerNames (never values); credential secrets return as hasServiceAccountKey. These shapes were built for a browser session — over an API key the old ones were a token-exfiltration primitive.
  • MCP create is a real create: 409 on a duplicate URL, checked before the lib's upsert can overwrite the existing server. {{ENV_VAR}} URLs are rejected (they skip the domain allowlist and SSRF resolve, so over a key that's a stored SSRF path), bodies are strict, and url must be an absolute http(s) URL.
  • Extracts lib/skills/orchestration/ and lib/credentials/orchestration/credential-create.ts, then repoints the existing session routes and copilot manage_skill at them. Skill field limits used to live only in the route's Zod contract, so copilot bypassed them entirely — now every caller gets the same rules. app/api/credentials/route.ts went 720 → 205 lines.
  • Hand-authored apps/docs/openapi-v2-resources.json (5 tags, 25 operations), registered in both SPEC_FILES lists and all 6 locale meta.jsons.

Type of Change

  • New feature

Testing

  • bun run type-check ✅, check:openapi ✅ (7 specs, 82 operations, 73 contracts cross-checked), check:api-validation ✅ (route baseline 1028 → 1038), lint:check
  • 172 new tests across 10 route files; vitest app/api/v2 lib/skills app/api/skills app/api/credentials app/api/folders app/api/tools lib/copilot1412 passed
  • Exercised live against a local dev server with a real API key and DB: full CRUD round-trip on all five families, plus the departures — header values confirmed absent from responses, duplicate MCP URL → 409 without clobbering, {{ENV}}/file:// → 400, built-in skill name → 400, custom-tool rename collision → 409, folder cascade counts, credential idempotent re-create returning the same id. Auth: no key → 401, bad key → 401, foreign workspace → 403. All test artifacts cleaned up.

Notes for review

  • check:api-validation:strict fails on this branch, but not because of this PR. The doubleCasts ratchet reads 9 vs a baseline of 8; all nine live in files this diff never touches (tools/hosting.ts, contracts/tables.ts, executor/utils/errors.ts, packages/logger, packages/ts-sdk) and all are present at the base commit. improvement(external-endpoints): v2 versions with clean signatures + updated docs based on openapi spec #5273's own Lint and Test is already FAILURE for the same reason. I did not bump the baseline — that would hide an existing regression inside an unrelated PR. Happy to bump it if you'd rather have green CI here.
  • Judgment calls worth a look: credentials create excludes oauth (needs an internal account.id from the browser flow); create always returns 201 including the idempotent source replay, because the OpenAPI checker only validates the numerically-smallest 2xx; folders require resourceType explicitly rather than defaulting to workflow; the skills list omits content (50k chars each) in favour of the detail endpoint; /api/skills POST is no longer a single transaction — it applies per item so one authority owns the rules.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 1, 2026 6:43am

Request Review

@cursor

cursor Bot commented Aug 1, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Large new public API surface over credentials, MCP URLs, and sandboxed custom-tool code, with security-sensitive read masking and secret handling that must stay correct on every path.

Overview
Introduces the Sim API v2 — Workspace Resources surface: full CRUD for MCP servers, skills, custom tools, folders, and credentials under /api/v2, with the usual v2 envelopes, rate limits, and feature-flag gate.

Secrets stay write-only on read — MCP headers surface as hasHeaders / headerNames; credentials use hasServiceAccountKey instead of returning encrypted material. Credential detail/list routes mask inaccessible credentials as 404 so membership cannot be enumerated. MCP create rejects templated {{ENV_VAR}} URLs and duplicate URLs with 409 before an upsert can overwrite.

Session routes are centralized — credential create/list moves into performCreateCredential and listVisibleWorkspaceCredentials; skills POST/DELETE use lib/skills/orchestration so copilot and the UI share the same field limits and editor checks. Provider outage codes map consistently to 503 via isProviderOutageCode. v2 credential create excludes oauth (browser connect flow only); idempotent creates still return 201.

Docs add openapi-v2-resources.json, register it in apps/docs/lib/openapi.ts, and add generated nav entries for all five resource families across locale meta.json files. Rate-limit buckets for the new v2 routes are added in v1 middleware.

Reviewed by Cursor Bugbot for commit 2b33a0e. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds public v2 CRUD endpoints and OpenAPI documentation for MCP servers, skills, custom tools, folders, and credentials, while extracting shared credential and skill orchestration.

  • Adds tenant-scoped API-key routes for five workspace resource families.
  • Keeps credential and MCP secret values write-only in API responses.
  • Reuses shared lifecycle and authorization logic across public and session-backed routes.
  • Registers the new resource specification throughout the localized documentation site.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the credential-role issue is fixed, and the folder-lock thread concerned unchanged behavior already reachable through the existing route.

Important Files Changed

Filename Overview
apps/sim/app/api/v2/credentials/route.ts Adds credential list/create endpoints and now resolves the actual authorization role for idempotently matched credentials.
apps/sim/lib/credentials/orchestration/credential-create.ts Centralizes credential creation, idempotent source matching, membership creation, and provider-specific validation.
apps/sim/app/api/v2/folders/[id]/route.ts Adds workspace-scoped folder read, update, and cascade-delete handlers using the existing lifecycle implementation.
apps/sim/lib/skills/orchestration/skill-lifecycle.ts Centralizes skill validation and lifecycle behavior so API and copilot callers share the same constraints.
apps/docs/openapi-v2-resources.json Documents the 25 public resource operations, request contracts, secret-redacted response shapes, and standard API errors.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Client[API client] --> Auth[API-key and workspace authorization]
  Auth --> V2[Public v2 resource routes]
  V2 --> MCP[MCP servers]
  V2 --> Skills[Skills]
  V2 --> Tools[Custom tools]
  V2 --> Folders[Folders]
  V2 --> Credentials[Credentials]
  Skills --> SkillLifecycle[Shared skill orchestration]
  Credentials --> CredentialLifecycle[Shared credential orchestration]
  MCP --> DB[(Workspace data)]
  SkillLifecycle --> DB
  Tools --> DB
  Folders --> DB
  CredentialLifecycle --> DB
  Specs[OpenAPI resource specification] -. documents .-> V2
Loading

Reviews (6): Last reviewed commit: "fix(credentials): use the shared outage ..." | Re-trigger Greptile

Comment thread apps/sim/app/api/v2/credentials/route.ts Outdated
Comment thread apps/sim/app/api/v2/folders/[id]/route.ts
Comment thread apps/sim/app/api/v2/mcp-servers/route.ts
Comment thread apps/sim/app/api/v2/skills/[id]/route.ts
Comment thread apps/sim/app/api/v2/mcp-servers/[id]/route.ts
Comment thread apps/sim/app/api/v2/custom-tools/route.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/api/v2/credentials/[id]/route.ts
Comment thread apps/sim/app/api/v2/credentials/[id]/route.ts
Comment thread apps/sim/app/api/v2/credentials/[id]/route.ts
Comment thread apps/sim/app/api/v2/custom-tools/utils.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/skills/orchestration/skill-lifecycle.ts
Comment thread apps/sim/app/api/v2/mcp-servers/route.ts
Comment thread apps/sim/app/api/v2/custom-tools/[id]/route.ts
Comment thread apps/sim/lib/credentials/orchestration/index.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/credentials/orchestration/credential-create.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/credentials/orchestration/credential-create.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2b33a0e. Configure here.

@TheodoreSpeaks
TheodoreSpeaks merged commit eddd53a into v2-api-spec Aug 1, 2026
5 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the feat/v2-resource-endpoints branch August 1, 2026 06:56
TheodoreSpeaks added a commit that referenced this pull request Aug 1, 2026
Brings the five new v2 resource families (MCP servers, skills, custom tools,
folders, credentials) from #6150 onto the branch, alongside the boundary-ratchet
fix. Both sides edited the ratchet script in different places; the combined
baselines are re-verified below.
TheodoreSpeaks added a commit that referenced this pull request Aug 1, 2026
#6150 branched before #6134, so skill-lifecycle.ts imports
@/lib/workflows/orchestration/types — the module #6134 moved to
@/lib/core/orchestration/types. Git merged a file deletion on one side with a
new file referencing it on the other: no textual conflict, broken build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
TheodoreSpeaks added a commit that referenced this pull request Aug 1, 2026
…sting them

Merges `v2-api-spec` (#6150 — v2 endpoints for MCP servers, skills, custom
tools, folders, credentials) and the newer `improvement/v2-endpoints`.

## The generator was list-driven, so none of it would have appeared

`DOMAINS` and `SPEC_FILES` were hardcoded. Five new contract modules and a new
`openapi-v2-resources.json` had landed, and the generator would have skipped
every one — silently, with `--check` still passing, because the generated file
matched a generator that never looked. Both are now discovered from disk.

That is the same silent-drop class the review rounds kept surfacing, and it is
the property the whole pipeline rests on: a new v2 domain should reach the CLI
by regenerating, not by remembering to edit a list.

Result: 47 → 72 operations, 13 contract modules, and 25 new commands
(`sim skills list`, `sim mcp-servers get`, `sim folders delete`, …) with no CLI
change beyond the discovery fix. Summaries for the new domains now resolve too,
so their `--help` reads properly instead of falling back to `METHOD /path`.

## Confirmation gates for the new destructive operations

Five new DELETEs arrived ungated. `deleteFolder` is the sharpest — the route
archives the folder *and cascades to its contents* — so its message says so
rather than reading like a single-item removal.

Added a test asserting every DELETE carries a confirmation, with
`undeployWorkflow` the one documented exception (reversible by redeploying). It
fails against this commit's own starting state, so the next domain to arrive
cannot land ungated the way these did.

## One fix outside the CLI

`lib/skills/orchestration/skill-lifecycle.ts`, added by #6150, imports
`OrchestrationErrorCode` from `@/lib/workflows/orchestration/types`, which does
not exist — the type lives in `@/lib/core/orchestration/types`, where every
other consumer reads it. The branch does not type-check without this.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsThUPqZXjwuuyRjBbmVkj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant