diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e87bd85 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,34 @@ +name: Test + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +jobs: + test: + name: Test and build + runs-on: ubuntu-22.04 + steps: + - name: Checkout repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Setup Node + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + with: + node-version: "24.14.0" + cache: "npm" + cache-dependency-path: ./package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test + + - name: Build + run: npm run build diff --git a/package-lock.json b/package-lock.json index 8537494..7a46612 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,6 @@ }, "devDependencies": { "@types/node": "^22.5.1", - "tsc": "^2.0.4", "tsup": "^8.2.4", "vitest": "^2.1.9" }, @@ -3568,16 +3567,6 @@ "dev": true, "license": "Apache-2.0" }, - "node_modules/tsc": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/tsc/-/tsc-2.0.4.tgz", - "integrity": "sha512-fzoSieZI5KKJVBYGvwbVZs/J5za84f2lSTLPYf6AGiIf43tZ3GNrI1QzTLcjtyDDP4aLxd46RTZq1nQxe7+k5Q==", - "dev": true, - "license": "MIT", - "bin": { - "tsc": "bin/tsc" - } - }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", diff --git a/package.json b/package.json index ffa7987..d56bf11 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "description": "The Infisical SDK provides a convenient way to programmatically interact with the Infisical API.", "devDependencies": { "@types/node": "^22.5.1", - "tsc": "^2.0.4", "tsup": "^8.2.4", "vitest": "^2.1.9" }, diff --git a/sink/agent-vault.test.ts b/sink/agent-vault.test.ts index 1cefccc..1f9c603 100644 --- a/sink/agent-vault.test.ts +++ b/sink/agent-vault.test.ts @@ -686,6 +686,37 @@ describe("agent vault inline services", () => { expect(lastRequest().body).toEqual({ projectId: PROJECT_ID, services }); }); + it("create sends an MCP server's tool list and reads it back", async () => { + const services: AgentVaultInlineServiceInput[] = [ + { + type: "mcp", + name: "deepwiki", + serverUrl: "https://mcp.deepwiki.com/mcp", + transport: "streamable-http", + credential: { type: "bearer", value: "mcp-token" }, + allowedTools: ["read_wiki_structure"] + } + ]; + const inline = { + id: INLINE_SERVICE.id, + name: "deepwiki", + description: null, + type: "mcp", + serverUrl: "https://mcp.deepwiki.com/mcp", + transport: "streamable-http", + hostPattern: "mcp.deepwiki.com", + allowedTools: ["read_wiki_structure"], + credential: { type: "bearer", headerName: "Authorization", headerPrefix: "Bearer" }, + customHeaders: [] + }; + respondWith({ session: { ...CREATED_SESSION, accessBundle: null, services: [inline] } }); + const created = await agentVault.sessions.create({ ...PROJECT, services }); + expect(lastRequest().body).toEqual({ projectId: PROJECT_ID, services }); + const [service] = created.services; + if (service.type !== "mcp") throw new Error("service was not narrowed"); + expect(service.allowedTools).toEqual(["read_wiki_structure"]); + }); + it("create sends an access bundle and services together", async () => { respondWith({ session: { ...CREATED_SESSION, services: [INLINE_SERVICE] } }); await agentVault.sessions.create({ ...PROJECT, accessBundle: "release", services: [INLINE_SERVICE_INPUT] }); diff --git a/src/api/types/agent-vault.ts b/src/api/types/agent-vault.ts index 04c1ce5..7a5ba14 100644 --- a/src/api/types/agent-vault.ts +++ b/src/api/types/agent-vault.ts @@ -204,6 +204,13 @@ export interface AgentVaultInlineMcpServiceInput { serverUrl: string; transport: AgentVaultMcpTransport; credential: AgentVaultInlineBearerCredential; + /** + * The MCP tools that agents can call through the service, by exact, case-sensitive name: each 1 to 128 letters, + * numbers, underscores, hyphens or dots. The proxy refuses a call to any other tool and leaves it out of the + * server's tool list. Leave it out, or send null, to allow every tool. Needs an Infisical version that + * accepts a tool list on a session's services; an older one refuses the session. + */ + allowedTools?: string[] | null; /** Up to 20. */ customHeaders?: AgentVaultInlineCustomHeader[]; } @@ -324,6 +331,11 @@ export interface AgentVaultInlineMcpService extends AgentVaultInlineServiceBase serverUrl: string; transport: AgentVaultMcpTransport; hostPattern: string; + /** + * The MCP tools that agents can call through the service, or null for every tool. Undefined from an Infisical + * version that doesn't return it. + */ + allowedTools?: string[] | null; credential: AgentVaultInlineBearerCredentialSummary; customHeaders: AgentVaultInlineCustomHeaderSummary[]; } @@ -872,9 +884,8 @@ export type CreateAgentVaultSessionOptions = { /** * Services the session carries itself, instead of or beside its access bundle's: up to 20. Only Agent Vault admins * can send them. Each has the same fields as a service in an access bundle, except that its name is optional for - * HTTP and MCP services (database and SSH services need one), its values can't use variables, it can't use OAuth - * or member-provided values, and an MCP server can't be limited to some of its tools. To limit an MCP server's - * tools, add it to an access bundle instead. + * HTTP and MCP services (database and SSH services need one), its values can't use variables, and it can't use + * OAuth or member-provided values. */ services?: AgentVaultInlineServiceInput[]; /** How long the session lasts: a duration such as "30m", "8h" or "7d" (at least 1m), or "never". Defaults to "7d", or to "1h" for a session on behalf of a user. */ diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 0000000..d3d4cea --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es2022", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "noEmit": true, + "types": ["node"] + }, + "include": ["sink/**/*.test.ts"] +} diff --git a/vitest.config.ts b/vitest.config.ts index 429cb41..c46e64d 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -4,5 +4,11 @@ export default defineConfig({ test: { environment: "node", include: ["sink/**/*.test.ts"], + // The build's tsconfig leaves sink out, so this is the only check that the tests compile against the SDK's types. + typecheck: { + enabled: true, + include: ["sink/**/*.test.ts"], + tsconfig: "./tsconfig.test.json", + }, }, });