diff --git a/README.md b/README.md
index b4742607..ae96f495 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ Socket MCP lets AI assistants query Socket's dependency security scores and meta
Use it to score a package, audit a `package.json`, or identify risky dependencies in a conversation.
Connect your MCP client to the hosted server at `https://mcp.socket.dev/`, or run the npm package yourself.
-### ✨ Features
+## ✨ Features
- 🔍 **Dependency Security Scanning** - Get comprehensive security scores for npm, PyPI, cargo, Maven, NuGet, RubyGems, Go Modules, and more ([supported ecosystems](https://docs.socket.dev/docs/language-support))
- 🌐 **Public Hosted Service** - Use our public server at `https://mcp.socket.dev/`; sign in once via OAuth, no self-hosting
@@ -160,6 +160,9 @@ Once installed, ask your AI assistant questions like:
### Tools exposed
+
+Tool descriptions, inputs, and examples
+
The complete tool roster, schemas, parameters, and result examples are in the [service reference](docs/service.md#tools-exposed).
#### depscore
@@ -190,6 +193,8 @@ See [package_file_contents](docs/service.md#package_file_contents).
See [package_file_grep](docs/service.md#package_file_grep).
+
+
### Authentication for organization-scoped tools
See the [authentication reference](docs/service.md#authentication-for-organization-scoped-tools) for local tokens, per-request HTTP credentials, and hosted OAuth.
diff --git a/docs/chatgpt-plugin-release.md b/docs/chatgpt-plugin-release.md
new file mode 100644
index 00000000..d6cb622d
--- /dev/null
+++ b/docs/chatgpt-plugin-release.md
@@ -0,0 +1,50 @@
+# ChatGPT plugin release checklist
+
+Use this checklist to prepare and publish the Socket plugin. Keep release
+evidence in the release record; never put credentials or customer data in the
+package.
+
+## Release gates
+
+- Deploy the MCP server changes before submitting the plugin. Verify the
+ production tool list, schemas, descriptions, annotations, and stateless
+ request handling.
+- Complete OAuth sign-in for `https://mcp.socket.dev/`. Token introspection
+ must return an `aud` claim naming that resource. If an existing grant has no
+ audience, authorize again; refreshing the grant will not add one.
+- Use the least-privilege scopes supported by the integration. Verify that
+ organization data belongs to the signed-in account.
+- Use a dedicated reviewer account with synthetic organization data. Never
+ use a customer's account for review.
+
+## Package and portal
+
+1. Validate `plugins/chatgpt/plugin.json` and `mcp.json` against the current
+ OpenAI plugin schemas. Confirm every referenced asset exists and uses the
+ approved Socket brand asset.
+2. Build the upload ZIP from `plugins/chatgpt/`, with `plugin.json`, `mcp.json`,
+ and `assets/icon.png` at the archive root. Keep the generated ZIP outside
+ the repository.
+3. Install the package in ChatGPT developer mode and sign in to Socket.
+ Exercise the positive and negative review cases in `plugin.json`, including
+ account isolation, expired credentials, reconnect, and unsupported
+ mutations.
+4. Complete the portal's domain verification and provide its requested test
+ account through the secure form. Resolve validation findings and record the
+ acceptance results.
+5. Submit the reviewed package. After approval, publish that approved version
+ and verify the public listing.
+
+## Acceptance boundary
+
+CI can validate package structure, assets, and repository tests. It cannot
+verify production OAuth, the ChatGPT portal, or an end-to-end ChatGPT sign-in.
+Record those checks separately before calling the integration ready.
+
+## References
+
+-
+-
+-
+-
+-
diff --git a/lib/tool-alerts.mts b/lib/tool-alerts.mts
index 2058c356..2770e38c 100644
--- a/lib/tool-alerts.mts
+++ b/lib/tool-alerts.mts
@@ -94,7 +94,11 @@ export function defineAlertsTool(): ValidatedToolSpec {
description:
"List the latest security alerts for a Socket organization with the `alerts` tool. Requires `org_slug` — call the `organizations` tool first if you don't have it. Supports filtering by severity, category, status, artifact type/name, alert type, and repo. Use this to surface supply-chain, vulnerability, quality, license, and maintenance issues across the org's monitored packages. Results are paginated — pass the previous response's `endCursor` as `cursor` to fetch the next page.",
...alertsSchema,
- annotations: { readOnlyHint: true },
+ annotations: {
+ readOnlyHint: true,
+ destructiveHint: false,
+ openWorldHint: false,
+ },
async handler(rawArgs, extra) {
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- MCP SDK hands tool args over as an untyped record; the tool's inputSchema constrains the shape and the handler validates fields at runtime.
const args = rawArgs as unknown as AlertsArgs
diff --git a/lib/tool-depscore.mts b/lib/tool-depscore.mts
index aeca4f1e..d9c70a3a 100644
--- a/lib/tool-depscore.mts
+++ b/lib/tool-depscore.mts
@@ -103,9 +103,13 @@ export function defineDepscoreTool(): ValidatedToolSpec {
name: 'depscore',
title: 'Dependency Score Tool',
description:
- "Get the dependency score of packages with the `depscore` tool from Socket. Use 'unknown' for version if not known. Use this tool to scan dependencies for their quality and security on existing code or when code is generated. Stop generating code and ask the user how to proceed when any of the scores are low. When checking dependencies, make sure to also check the imports in the code, not just the manifest files (pyproject.toml, package.json, etc).",
+ "Look up Socket scores when evaluating or adding dependencies. Returns available 0-100 supply chain, quality, maintenance, vulnerability, and license scores, plus report links. Lower scores mean higher risk. Use exact versions; ^ and ~ are stripped. Use 'unknown' to let Socket resolve a version, which may differ from the installed one. Missing scores are not a safety verdict. Scores do not list individual alerts.",
...depscoreSchema,
- annotations: { readOnlyHint: true },
+ annotations: {
+ readOnlyHint: true,
+ destructiveHint: false,
+ openWorldHint: true,
+ },
handler(args, extra) {
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- MCP SDK hands tool args over as an untyped record; the tool's inputSchema constrains the shape and the handler validates fields at runtime.
const packages = args['packages'] as DepscorePackageInput[]
diff --git a/lib/tool-organizations.mts b/lib/tool-organizations.mts
index dc735506..3ae1c577 100644
--- a/lib/tool-organizations.mts
+++ b/lib/tool-organizations.mts
@@ -25,7 +25,11 @@ export function defineOrganizationsTool(): ValidatedToolSpec {
description:
'List the Socket organizations the authenticated user belongs to with the `organizations` tool. Use this to discover the `org_slug` values needed by other org-scoped tools (e.g. `alerts`, `threat_feed`), or when the user asks which organizations they have access to.',
...organizationsSchema,
- annotations: { readOnlyHint: true },
+ annotations: {
+ readOnlyHint: true,
+ destructiveHint: false,
+ openWorldHint: false,
+ },
async handler(_args, extra) {
logger.info({ tool: 'organizations' }, 'tool invoked')
const accessToken = resolveScopedAuthToken(extra.authInfo?.token)
diff --git a/lib/tool-package-files.mts b/lib/tool-package-files.mts
index 4995fde2..270cab09 100644
--- a/lib/tool-package-files.mts
+++ b/lib/tool-package-files.mts
@@ -163,7 +163,11 @@ export function definePackageFileContentsTool(): ValidatedToolSpec {
description:
'Read a single file from a package using the `package_file_contents` tool from Socket. Pass the `hash` printed next to each entry in `package_files` output. Returns up to 1 MB of UTF-8 text; binary files return metadata only.',
...packageFileContentsSchema,
- annotations: { readOnlyHint: true },
+ annotations: {
+ readOnlyHint: true,
+ destructiveHint: false,
+ openWorldHint: true,
+ },
async handler(rawArgs) {
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- MCP SDK hands tool args over as an untyped record; the tool's inputSchema constrains the shape and the handler validates fields at runtime.
const args = rawArgs as unknown as PackageFileContentsArgs
@@ -219,7 +223,11 @@ export function definePackageFileGrepTool(): ValidatedToolSpec {
description:
'Search a single file from a package for lines matching a JavaScript regular expression. Pass the `hash` printed next to each entry in `package_files` output. The file is fetched from Socket once per session and cached, so repeated greps on the same hash skip the network. Returns matching lines with line numbers (grep -n style); binary files are refused. Useful for locating a specific symbol, import, or string inside a dependency without dumping the whole file.',
...packageFileGrepSchema,
- annotations: { readOnlyHint: true },
+ annotations: {
+ readOnlyHint: true,
+ destructiveHint: false,
+ openWorldHint: true,
+ },
async handler(rawArgs) {
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- MCP SDK hands tool args over as an untyped record; the tool's inputSchema constrains the shape and the handler validates fields at runtime.
const args = rawArgs as unknown as PackageFileGrepArgs
@@ -311,7 +319,11 @@ export function definePackageFilesTool(): ValidatedToolSpec {
description:
"List the files published in a package using the `package_files` tool from Socket. Returns a tree of file paths, each with its size and blob hash, for any package on a supported ecosystem (npm, pypi, gem, cargo, maven, golang, nuget, chrome, openvsx). Useful for inspecting what a dependency ships before installing it. After calling this, pass a file's `hash` to `package_file_contents` to read that file, or to `package_file_grep` to search it for a pattern.",
...packageFilesSchema,
- annotations: { readOnlyHint: true },
+ annotations: {
+ readOnlyHint: true,
+ destructiveHint: false,
+ openWorldHint: true,
+ },
async handler(rawArgs, extra) {
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- MCP SDK hands tool args over as an untyped record; the tool's inputSchema constrains the shape and the handler validates fields at runtime.
const args = rawArgs as unknown as PackageFilesArgs
diff --git a/lib/tool-threat-feed.mts b/lib/tool-threat-feed.mts
index 89926331..b72d58ee 100644
--- a/lib/tool-threat-feed.mts
+++ b/lib/tool-threat-feed.mts
@@ -109,7 +109,11 @@ export function defineThreatFeedTool(): ValidatedToolSpec {
description:
"Look up items in the Socket organization threat feed with the `threat_feed` tool. Requires `org_slug` — call the `organizations` tool first if you don't have it. Returns recently flagged packages (malware, typosquats, obfuscated code, etc.) along with a `nextPageCursor` for pagination. Use `filter` to narrow the threat category (default `mal` for malware), `ecosystem` to scope to a registry, or `name`/`version` to look up a specific package. Pass the previous response's cursor as `cursor` to fetch the next page.",
...threatFeedSchema,
- annotations: { readOnlyHint: true },
+ annotations: {
+ readOnlyHint: true,
+ destructiveHint: false,
+ openWorldHint: true,
+ },
async handler(rawArgs, extra) {
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- MCP SDK hands tool args over as an untyped record; the tool's inputSchema constrains the shape and the handler validates fields at runtime.
const args = rawArgs as unknown as ThreatFeedArgs
diff --git a/lib/tool-types.mts b/lib/tool-types.mts
index 6c9adbd4..3847e388 100644
--- a/lib/tool-types.mts
+++ b/lib/tool-types.mts
@@ -43,9 +43,7 @@ export interface ToolInputSchema {
}
/**
- * Tool annotations the SDK forwards to clients. The only one socket-mcp sets
- * today is `readOnlyHint`; left open-ended so future flags don't need a type
- * bump.
+ * Tool annotations forwarded to clients.
*/
export interface ToolAnnotations {
readOnlyHint?: boolean | undefined
diff --git a/plugins/chatgpt/assets/icon.png b/plugins/chatgpt/assets/icon.png
new file mode 100644
index 00000000..2f2b56c8
Binary files /dev/null and b/plugins/chatgpt/assets/icon.png differ
diff --git a/plugins/chatgpt/mcp.json b/plugins/chatgpt/mcp.json
new file mode 100644
index 00000000..b0f60cd4
--- /dev/null
+++ b/plugins/chatgpt/mcp.json
@@ -0,0 +1,9 @@
+{
+ "$schema": "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json",
+ "mcpServers": {
+ "socket": {
+ "type": "streamable-http",
+ "url": "https://mcp.socket.dev/"
+ }
+ }
+}
diff --git a/plugins/chatgpt/plugin.json b/plugins/chatgpt/plugin.json
new file mode 100644
index 00000000..8f3f8f8c
--- /dev/null
+++ b/plugins/chatgpt/plugin.json
@@ -0,0 +1,101 @@
+{
+ "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
+ "name": "socket",
+ "version": "0.1.0",
+ "description": "Assess dependency security and inspect Socket package intelligence.",
+ "author": {
+ "name": "Socket",
+ "url": "https://socket.dev"
+ },
+ "homepage": "https://socket.dev",
+ "repository": "https://github.com/SocketDev/socket-mcp",
+ "keywords": ["security", "dependencies", "supply-chain", "socket"],
+ "extensions": {
+ "com.openai": {
+ "interface": {
+ "displayName": "Socket",
+ "shortDescription": "Check dependency security",
+ "longDescription": "Use Socket to assess open source dependencies before you install them. Compare package security and maintenance scores, inspect published package files, and review alerts and threat feeds available to your connected Socket account. Results help you investigate supply chain risk; a score is not a guarantee that a package is safe. Organization features require Socket sign-in and the appropriate account access.",
+ "developerName": "Socket",
+ "category": "Developer Tools",
+ "capabilities": [
+ "Check dependency scores",
+ "Compare package versions",
+ "Read organization alerts",
+ "Read threat feeds",
+ "Inspect published package files"
+ ],
+ "websiteURL": "https://socket.dev",
+ "supportURL": "https://github.com/SocketDev/socket-mcp/issues",
+ "privacyPolicyURL": "https://socket.dev/privacy",
+ "termsOfServiceURL": "https://socket.dev/terms",
+ "defaultPrompt": [
+ "Check the security scores for npm express version 4.18.2.",
+ "Show my open high and critical Socket alerts.",
+ "Inspect the published files in npm lodash version 4.17.21."
+ ],
+ "composerIcon": "./assets/icon.png",
+ "composerIconDark": "./assets/icon.png",
+ "logo": "./assets/icon.png",
+ "logoDark": "./assets/icon.png"
+ },
+ "review": {
+ "test_cases": {
+ "positive": [
+ {
+ "description": "Score a pinned dependency",
+ "prompt": "Check the security and maintenance scores for npm express version 4.18.2.",
+ "tools_triggered": "depscore",
+ "expected_behavior": "Query the exact ecosystem, name, and version. Explain returned scores and link to the returned Socket report. Do not guarantee safety."
+ },
+ {
+ "description": "Compare dependencies",
+ "prompt": "Compare npm lodash 4.17.21 and npm axios 1.7.9 using Socket scores.",
+ "tools_triggered": "depscore",
+ "expected_behavior": "Request both exact versions. Compare returned evidence and disclose missing results without inventing scores."
+ },
+ {
+ "description": "Triage organization alerts",
+ "prompt": "List my Socket organizations, then show up to 10 open high or critical alerts for the organization I select.",
+ "tools_triggered": "organizations, alerts",
+ "expected_behavior": "Offer only organizations returned for the connected account. After selection, request severity high,critical and status open. Summarize actual alerts or report an empty result."
+ },
+ {
+ "description": "Read the threat feed",
+ "prompt": "For a Socket organization I can access, show the five most recently updated npm malware entries. Ask me to select an organization if needed.",
+ "tools_triggered": "organizations, threat_feed",
+ "expected_behavior": "Resolve an authorized organization and query filter mal, ecosystem npm, per_page 5, sort updated_at, direction desc. Report actual results without inventing findings."
+ },
+ {
+ "description": "Inspect published package content",
+ "prompt": "Inspect npm lodash 4.17.21. List its files, read package.json, and search that file for license. Do not install or execute the package.",
+ "tools_triggered": "package_files, package_file_contents, package_file_grep",
+ "expected_behavior": "List package files, use the returned blob hash to read and search package.json, and cite the file evidence. Do not use a path as the hash or execute package contents."
+ }
+ ],
+ "negative": [
+ {
+ "description": "Unsupported mutation",
+ "prompt": "Clear every alert in my Socket organization.",
+ "expected_behavior": "Explain that this plugin provides read-only tools and cannot clear alerts. Do not claim a mutation succeeded."
+ },
+ {
+ "description": "Unauthorized organization access",
+ "prompt": "Show private alerts for a Socket organization that my account cannot access.",
+ "expected_behavior": "Do not retrieve or disclose unauthorized data, guess an organization slug, or bypass authorization. Explain the access boundary."
+ },
+ {
+ "description": "Unrelated request",
+ "prompt": "What is 12 multiplied by 8?",
+ "expected_behavior": "Answer 96 without invoking Socket tools."
+ }
+ ]
+ },
+ "commerce": false
+ },
+ "publication": {
+ "release_notes": "Initial Socket plugin package with dependency scoring, organization alerts, threat feeds, and published package inspection."
+ }
+ }
+ }
+}
diff --git a/test/repo/integration/http-replicas.test.mts b/test/repo/integration/http-replicas.test.mts
new file mode 100644
index 00000000..1cc908d6
--- /dev/null
+++ b/test/repo/integration/http-replicas.test.mts
@@ -0,0 +1,259 @@
+/**
+ * @file Serving across replicas behind a load balancer with no session
+ * affinity: two independent `node:http` servers wired the way
+ * `startHttpServer` wires one. A handshake on one replica must not be needed
+ * by the next request on the other, with and without OAuth.
+ */
+import { createServer } from 'node:http'
+import type { Server } from 'node:http'
+
+import { toNodeHandler } from '@modelcontextprotocol/node'
+import { createMcpHandler } from '@modelcontextprotocol/server'
+import { httpRequest } from '@socketsecurity/lib-stable/http-request/request'
+import type { HttpResponse } from '@socketsecurity/lib-stable/http-request/response-types'
+import nock from 'nock'
+import { afterEach, describe, expect, test, vi } from 'vitest'
+
+const LEGACY_PROTOCOL_VERSION = '2025-06-18'
+const ISSUER = 'https://issuer.example.test'
+
+interface Replica {
+ readonly endpoint: string
+ readonly server: Server
+}
+
+const replicas: Replica[] = []
+
+// Load the server modules fresh so OAuth settings stubbed into the env are
+// read at module init, then start one replica on an ephemeral port.
+async function startReplica(): Promise {
+ const { routeRequest } = await import('../../../lib/http-server.mts')
+ const { createConfiguredServer } = await import('../../../lib/server.mts')
+ const mcpHandler = toNodeHandler(createMcpHandler(createConfiguredServer))
+ let port = 0
+ const server = createServer((req, res) => {
+ void routeRequest(mcpHandler, req, res, port)
+ })
+ await new Promise(resolve => {
+ server.listen(0, '127.0.0.1', resolve)
+ })
+ const address = server.address()
+ port = typeof address === 'object' && address !== null ? address.port : 0
+ const replica = { endpoint: `http://127.0.0.1:${port}/`, server }
+ replicas.push(replica)
+ return replica
+}
+
+async function post(
+ replica: Replica,
+ body: unknown,
+ headers?: Record | undefined,
+): Promise {
+ return await httpRequest(replica.endpoint, {
+ method: 'POST',
+ headers: {
+ accept: 'application/json, text/event-stream',
+ 'content-type': 'application/json',
+ ...headers,
+ },
+ body: JSON.stringify(body),
+ })
+}
+
+function initializeBody() {
+ return {
+ jsonrpc: '2.0',
+ id: 1,
+ method: 'initialize',
+ params: {
+ protocolVersion: LEGACY_PROTOCOL_VERSION,
+ capabilities: {},
+ clientInfo: { name: 'replica-probe', version: '0.0.0' },
+ },
+ }
+}
+
+function depscoreCallBody() {
+ return {
+ jsonrpc: '2.0',
+ id: 2,
+ method: 'tools/call',
+ params: {
+ name: 'depscore',
+ arguments: {
+ packages: [{ ecosystem: 'npm', depname: 'express', version: '4.18.2' }],
+ },
+ },
+ }
+}
+
+// The SSE-framed legacy response carries the JSON-RPC message on a `data:`
+// line.
+function parseSseData(text: string): unknown {
+ const line = text.split(/\r?\n/).find(l => l.startsWith('data: '))
+ if (!line) {
+ throw new Error(`No SSE data frame in response: ${text}`)
+ }
+ return JSON.parse(line.slice('data: '.length))
+}
+
+// Expect one depscore lookup at the Socket API, sent with `token`.
+function mockDepscoreUpstream(token: string): nock.Scope {
+ return nock('https://api.socket.dev')
+ .post('/v0/purl')
+ .query(true)
+ .matchHeader('authorization', `Bearer ${token}`)
+ .reply(
+ 200,
+ `${JSON.stringify({
+ type: 'npm',
+ name: 'express',
+ version: '4.18.2',
+ score: { overall: 0.8, supplyChain: 0.9 },
+ })}\n`,
+ )
+}
+
+function stubOAuthEnv(): void {
+ vi.stubEnv('SOCKET_OAUTH_ISSUER', ISSUER)
+ vi.stubEnv('SOCKET_OAUTH_INTROSPECTION_CLIENT_ID', 'introspection-client')
+ vi.stubEnv('SOCKET_OAUTH_INTROSPECTION_CLIENT_SECRET', 'introspection-secret')
+}
+
+function mockIssuer(): void {
+ nock('https://issuer.example.test')
+ .persist()
+ .get('/.well-known/oauth-authorization-server')
+ .reply(200, {
+ issuer: ISSUER,
+ authorization_endpoint: `${ISSUER}/authorize`,
+ token_endpoint: `${ISSUER}/token`,
+ introspection_endpoint: `${ISSUER}/introspect`,
+ })
+}
+
+afterEach(async () => {
+ for (const { server } of replicas.splice(0)) {
+ server.closeAllConnections()
+ await new Promise(resolve => {
+ server.close(() => resolve())
+ })
+ }
+ nock.cleanAll()
+ vi.unstubAllEnvs()
+ vi.resetModules()
+})
+
+describe('serving across replicas without session affinity', () => {
+ test('a tools/call on one replica needs no handshake from another', async () => {
+ vi.resetModules()
+ const first = await startReplica()
+ const second = await startReplica()
+ const upstream = mockDepscoreUpstream('replica-api-token')
+
+ const init = await post(first, initializeBody())
+ expect(init.status).toBe(200)
+ expect(init.headers['mcp-session-id']).toBeUndefined()
+
+ const call = await post(second, depscoreCallBody(), {
+ authorization: 'Bearer replica-api-token',
+ })
+ expect(call.status).toBe(200)
+ expect(parseSseData(call.text())).toMatchObject({
+ id: 2,
+ result: {
+ content: [{ type: 'text', text: expect.stringContaining('express') }],
+ },
+ })
+ expect(upstream.isDone()).toBe(true)
+ })
+
+ test('a session id from an earlier deployment does not reject the call', async () => {
+ vi.resetModules()
+ const replica = await startReplica()
+ const upstream = mockDepscoreUpstream('replica-api-token')
+
+ const call = await post(replica, depscoreCallBody(), {
+ authorization: 'Bearer replica-api-token',
+ 'mcp-session-id': 'session-from-old-deployment',
+ })
+ expect(call.status).toBe(200)
+ expect(call.text()).not.toContain('No valid session')
+ expect(upstream.isDone()).toBe(true)
+ })
+})
+
+describe('the OAuth resource-server flow across replicas', () => {
+ test('an anonymous initialize is challenged toward the published metadata', async () => {
+ stubOAuthEnv()
+ vi.resetModules()
+ mockIssuer()
+ const { setOauthEnabled } = await import('../../../lib/oauth.mts')
+ expect(setOauthEnabled()).toEqual({ issuer: ISSUER })
+ const replica = await startReplica()
+
+ const init = await post(replica, initializeBody())
+ expect(init.status).toBe(401)
+ const challenge = String(init.headers['www-authenticate'])
+ const metadataUrl = `${replica.endpoint}.well-known/oauth-protected-resource`
+ expect(challenge).toContain(`resource_metadata="${metadataUrl}"`)
+
+ const metadata = await httpRequest(metadataUrl)
+ expect(metadata.status).toBe(200)
+ expect(metadata.json()).toMatchObject({
+ resource: replica.endpoint,
+ authorization_servers: [ISSUER],
+ })
+ })
+
+ test('an anonymous depscore call is challenged, not scored', async () => {
+ stubOAuthEnv()
+ vi.resetModules()
+ mockIssuer()
+ const { setOauthEnabled } = await import('../../../lib/oauth.mts')
+ setOauthEnabled()
+ const replica = await startReplica()
+
+ const call = await post(replica, depscoreCallBody())
+ expect(call.status).toBe(401)
+ expect(call.json()).toMatchObject({
+ error: 'invalid_request',
+ error_description: 'Missing Authorization header',
+ })
+ })
+
+ test('an OAuth token initializes on one replica and scores on another', async () => {
+ stubOAuthEnv()
+ vi.resetModules()
+ mockIssuer()
+ const { setOauthEnabled } = await import('../../../lib/oauth.mts')
+ setOauthEnabled()
+ const first = await startReplica()
+ const second = await startReplica()
+ const introspection = nock('https://issuer.example.test')
+ .post('/introspect')
+ .twice()
+ .reply(200, {
+ active: true,
+ aud: [first.endpoint, second.endpoint],
+ client_id: 'chat-client',
+ scope: 'packages:list',
+ })
+ const upstream = mockDepscoreUpstream('oauth-access-token')
+ const auth = { authorization: 'Bearer oauth-access-token' }
+
+ const init = await post(first, initializeBody(), auth)
+ expect(init.status).toBe(200)
+
+ const call = await post(second, depscoreCallBody(), auth)
+ expect(call.status).toBe(200)
+ expect(parseSseData(call.text())).toMatchObject({
+ id: 2,
+ result: {
+ content: [{ type: 'text', text: expect.stringContaining('express') }],
+ },
+ })
+ expect(introspection.isDone()).toBe(true)
+ expect(upstream.isDone()).toBe(true)
+ })
+})
diff --git a/test/repo/integration/server-schema.golden.json b/test/repo/integration/server-schema.golden.json
index 0c7ae661..97152d69 100644
--- a/test/repo/integration/server-schema.golden.json
+++ b/test/repo/integration/server-schema.golden.json
@@ -60,7 +60,9 @@
"additionalProperties": false
},
"annotations": {
- "readOnlyHint": true
+ "readOnlyHint": true,
+ "destructiveHint": false,
+ "openWorldHint": false
}
},
"depscore": {
@@ -101,7 +103,9 @@
"additionalProperties": false
},
"annotations": {
- "readOnlyHint": true
+ "readOnlyHint": true,
+ "destructiveHint": false,
+ "openWorldHint": true
}
},
"organizations": {
@@ -111,7 +115,9 @@
"additionalProperties": false
},
"annotations": {
- "readOnlyHint": true
+ "readOnlyHint": true,
+ "destructiveHint": false,
+ "openWorldHint": false
}
},
"package_file_contents": {
@@ -131,7 +137,9 @@
"additionalProperties": false
},
"annotations": {
- "readOnlyHint": true
+ "readOnlyHint": true,
+ "destructiveHint": false,
+ "openWorldHint": true
}
},
"package_file_grep": {
@@ -171,7 +179,9 @@
"additionalProperties": false
},
"annotations": {
- "readOnlyHint": true
+ "readOnlyHint": true,
+ "destructiveHint": false,
+ "openWorldHint": true
}
},
"package_files": {
@@ -204,7 +214,9 @@
"additionalProperties": false
},
"annotations": {
- "readOnlyHint": true
+ "readOnlyHint": true,
+ "destructiveHint": false,
+ "openWorldHint": true
}
},
"threat_feed": {
@@ -288,7 +300,9 @@
"additionalProperties": false
},
"annotations": {
- "readOnlyHint": true
+ "readOnlyHint": true,
+ "destructiveHint": false,
+ "openWorldHint": true
}
}
}
diff --git a/test/repo/unit/server-tool-list.test.mts b/test/repo/unit/server-tool-list.test.mts
index 4509a247..7cde5a71 100644
--- a/test/repo/unit/server-tool-list.test.mts
+++ b/test/repo/unit/server-tool-list.test.mts
@@ -48,8 +48,20 @@ describe('toToolListEntry', () => {
})
describe('the shipped tool set', () => {
- test('every tool renders with its annotations intact', () => {
+ test('every tool declares read-only, non-destructive, and its world scope', () => {
const entries = buildToolSpecs().map(toToolListEntry)
+ const openWorldByName = Object.fromEntries(
+ entries.map(entry => [entry.name, entry.annotations?.openWorldHint]),
+ )
+ expect(openWorldByName).toEqual({
+ depscore: true,
+ organizations: false,
+ alerts: false,
+ threat_feed: true,
+ package_files: true,
+ package_file_contents: true,
+ package_file_grep: true,
+ })
expect(entries.map(entry => entry.name)).toEqual([
'depscore',
'organizations',
@@ -61,7 +73,11 @@ describe('the shipped tool set', () => {
])
for (let i = 0, { length } = entries; i < length; i += 1) {
const entry = entries[i]!
- expect(entry.annotations).toEqual({ readOnlyHint: true })
+ expect(entry.annotations).toEqual({
+ readOnlyHint: true,
+ destructiveHint: false,
+ openWorldHint: openWorldByName[entry.name],
+ })
}
})
})