Skip to content
Merged
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
57 changes: 57 additions & 0 deletions .config/repo/conformance-baseline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Known MCP conformance failures for scripts/conformance.mts
# (@modelcontextprotocol/conformance, spec 2025-11-25).
#
# The CLI exits 1 on a failure that is not listed here (a regression) and on a
# listed scenario that now passes (a stale entry: delete it). Every entry has a
# one-line reason. socket-mcp advertises only the `tools` capability, and the
# tools-call-* scenarios call fixture tools (test_image_content, ...) that only
# the suite's reference server defines.
server:
# No `logging` capability: logging/setLevel answers -32601.
- logging-set-level
# No `completions` capability: completion/complete answers -32601.
- completion-complete
# Fixture tool test_image_content does not exist; no tool returns images.
- tools-call-image
# Fixture tool test_audio_content does not exist; no tool returns audio.
- tools-call-audio
# Fixture tool test_embedded_resource does not exist; no tool embeds resources.
- tools-call-embedded-resource
# Fixture tool test_multiple_content_types does not exist; tools return text only.
- tools-call-mixed-content
# No `logging` capability, so the tool cannot emit log notifications.
- tools-call-with-logging
# Fixture tool test_tool_with_progress does not exist; tools send no progress.
- tools-call-with-progress
# Fixture tool test_sampling does not exist; the server never requests sampling.
- tools-call-sampling
# Fixture tool test_elicitation does not exist; the server never elicits.
- tools-call-elicitation
# Fixture tool for SEP-1034 elicitation defaults does not exist; no elicitation.
- elicitation-sep1034-defaults
# Fixture tool for SEP-1330 elicitation enums does not exist; no elicitation.
- elicitation-sep1330-enums
# No `resources` capability: resources/list answers -32601.
- resources-list
# No `resources` capability: resources/read answers -32601.
- resources-read-text
# No `resources` capability: resources/read answers -32601.
- resources-read-binary
# No `resources` capability: resources/templates/list answers -32601.
- resources-templates-read
# No `resources` capability: resources/subscribe answers -32601.
- resources-subscribe
# No `resources` capability: resources/unsubscribe answers -32601.
- resources-unsubscribe
# No `prompts` capability: prompts/list answers -32601.
- prompts-list
# No `prompts` capability: prompts/get answers -32601.
- prompts-get-simple
# No `prompts` capability: prompts/get answers -32601.
- prompts-get-with-args
# No `prompts` capability: prompts/get answers -32601.
- prompts-get-embedded-resource
# No `prompts` capability: prompts/get answers -32601.
- prompts-get-with-image
# Stateless serving issues no Mcp-Session-Id by design; the scenario only warns, and baseline mode counts a warning as a failure.
- server-sse-multiple-streams
32 changes: 32 additions & 0 deletions .github/workflows/ci-gates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,35 @@ jobs:
path: ${{ env.SOCKET_MCP_TERMINAL_ARTIFACTS }}
include-hidden-files: true
if-no-files-found: ignore

conformance:
name: MCP conformance
runs-on: ubuntu-26.04
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: .node-version
- name: Install pnpm
run: npm install --global pnpm@12.14.0
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
# Starts the built server in HTTP mode on localhost with a dummy Socket
# API token and runs @modelcontextprotocol/conformance against it. Fails
# on a scenario missing from .config/repo/conformance-baseline.yaml or on
# a baseline entry that now passes.
- name: Run MCP conformance suite
run: pnpm run conformance
- name: Upload conformance results
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: mcp-conformance
path: .cache/conformance
include-hidden-files: true
if-no-files-found: ignore
35 changes: 18 additions & 17 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,24 @@ The transport is stateless. Each `POST /` is self-contained, with no session to

Environment variables for HTTP mode:

| Variable | Required | Default | Description |
| ------------------------------------------ | ----------------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MCP_HTTP_MODE` | Yes, unless you pass `--http` | `false` | Set to `true` to serve HTTP instead of stdio. The `--http` CLI flag does the same thing. |
| `MCP_PORT` | No | `3000` | Port to bind the HTTP server to. |
| `SOCKET_API_TOKEN` | Optional | None | API token for outbound API calls. Use it only as a fallback for local stdio. `socket-mcp login` is the recommended local sign-in. HTTP OAuth does not need a startup token. See the alias list below. |
| `SOCKET_OAUTH_ISSUER` | With OAuth | None | OAuth issuer URL. Must be `https` on a public host. See "Enabling OAuth" below. |
| `SOCKET_OAUTH_INTROSPECTION_CLIENT_ID` | With OAuth | None | Client ID used for RFC 7662 token introspection. |
| `SOCKET_OAUTH_INTROSPECTION_CLIENT_SECRET` | With OAuth | None | Client secret used for RFC 7662 token introspection. |
| `SOCKET_OAUTH_REQUIRED_SCOPES` | No | None | Scopes required on incoming access tokens, separated by spaces or commas. When unset, any active token passes. |
| `SOCKET_API_BASE_URL` | No | None | Override the upstream Socket API endpoint. Falls back to `https://api.socket.dev` when unset. |
| `SOCKET_MCP_OAUTH_BASE_URL` | No | API URL | Override the issuer used by local stdio OAuth. By default, OAuth follows `SOCKET_API_BASE_URL`; an `api.` hostname maps to its matching `mcp.` resource host. Non-loopback URLs must use HTTPS. |
| `SOCKET_DEBUG` | No | `false` | Turns on verbose request and cache tracing on stderr, points `depscore` at `http://localhost:8866`, and permits a local OAuth issuer. |
| `SOCKET_MCP_APPS_CHALLENGE_TOKEN` | For domain verification | None | Token the OpenAI plugin portal issues for domain verification. When set, `GET /.well-known/openai-apps-challenge` returns it as plain text; when unset, that path returns `404`. |
| `SOCKET_MCP_SENTRY_DSN` | No | None | Sentry DSN for error reporting; it must use HTTPS. When unset, reporting is off: the Sentry SDK is never loaded and nothing is sent. When set, HTTP mode sends scrubbed events for server-side failures. See [Error reporting](service.md#error-reporting). |
| `SOCKET_MCP_SENTRY_ENVIRONMENT` | No | `production` | Sentry `environment` reported events carry, such as `staging`. Read only when `SOCKET_MCP_SENTRY_DSN` is set. |
| `SOCKET_MCP_SENTRY_TRACES_SAMPLE_RATE` | No | `0` | Share of `tools/call` requests sent to Sentry as transactions, from 0 to 1. `0`, unset or out of range sends none. Read only when `SOCKET_MCP_SENTRY_DSN` is set. See [Tracing](service.md#tracing). |
| `TRUST_PROXY` | No | `false` | Trust `X-Forwarded-Host` and `X-Forwarded-Proto` when building OAuth metadata URLs. Enable only behind a reverse proxy that rewrites them. |
| Variable | Required | Default | Description |
| ------------------------------------------ | ----------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MCP_HTTP_MODE` | Yes, unless you pass `--http` | `false` | Set to `true` to serve HTTP instead of stdio. The `--http` CLI flag does the same thing. |
| `MCP_HOST` | No | All interfaces | Address to bind the HTTP server to, for example `127.0.0.1` to accept loopback connections only. |
| `MCP_PORT` | No | `3000` | Port to bind the HTTP server to. |
| `SOCKET_API_TOKEN` | Optional | None | API token for outbound API calls. Use it only as a fallback for local stdio. `socket-mcp login` is the recommended local sign-in. HTTP OAuth does not need a startup token. See the alias list below. |
| `SOCKET_OAUTH_ISSUER` | With OAuth | None | OAuth issuer URL. Must be `https` on a public host. See "Enabling OAuth" below. |
| `SOCKET_OAUTH_INTROSPECTION_CLIENT_ID` | With OAuth | None | Client ID used for RFC 7662 token introspection. |
| `SOCKET_OAUTH_INTROSPECTION_CLIENT_SECRET` | With OAuth | None | Client secret used for RFC 7662 token introspection. |
| `SOCKET_OAUTH_REQUIRED_SCOPES` | No | None | Scopes required on incoming access tokens, separated by spaces or commas. When unset, any active token passes. |
| `SOCKET_API_BASE_URL` | No | None | Override the upstream Socket API endpoint. Falls back to `https://api.socket.dev` when unset. |
| `SOCKET_MCP_OAUTH_BASE_URL` | No | API URL | Override the issuer used by local stdio OAuth. By default, OAuth follows `SOCKET_API_BASE_URL`; an `api.` hostname maps to its matching `mcp.` resource host. Non-loopback URLs must use HTTPS. |
| `SOCKET_DEBUG` | No | `false` | Turns on verbose request and cache tracing on stderr, points `depscore` at `http://localhost:8866`, and permits a local OAuth issuer. |
| `SOCKET_MCP_APPS_CHALLENGE_TOKEN` | For domain verification | None | Token the OpenAI plugin portal issues for domain verification. When set, `GET /.well-known/openai-apps-challenge` returns it as plain text; when unset, that path returns `404`. |
| `SOCKET_MCP_SENTRY_DSN` | No | None | Sentry DSN for error reporting; it must use HTTPS. When unset, reporting is off: the Sentry SDK is never loaded and nothing is sent. When set, HTTP mode sends scrubbed events for server-side failures. See [Error reporting](service.md#error-reporting). |
| `SOCKET_MCP_SENTRY_ENVIRONMENT` | No | `production` | Sentry `environment` reported events carry, such as `staging`. Read only when `SOCKET_MCP_SENTRY_DSN` is set. |
| `SOCKET_MCP_SENTRY_TRACES_SAMPLE_RATE` | No | `0` | Share of `tools/call` requests sent to Sentry as transactions, from 0 to 1. `0`, unset or out of range sends none. Read only when `SOCKET_MCP_SENTRY_DSN` is set. See [Tracing](service.md#tracing). |
| `TRUST_PROXY` | No | `false` | Trust `X-Forwarded-Host` and `X-Forwarded-Proto` when building OAuth metadata URLs. Enable only behind a reverse proxy that rewrites them. |

The three OAuth variables are a set: configure all three or none. Setting only some of them makes the server print `Incomplete OAuth configuration for HTTP mode` and exit `1`, rather than quietly start unauthenticated.

Expand Down
5 changes: 4 additions & 1 deletion lib/cli.mts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { errorMessage } from '@socketsecurity/lib/errors/message'

import {
getMcpHttpMode,
getMcpHost,
getMcpPort,
getSocketApiToken,
getSocketMcpSentryDsn,
Expand Down Expand Up @@ -46,6 +47,7 @@ export interface SocketMcpCliDeps {
readonly apiToken: string | undefined
readonly argv: readonly string[]
readonly envHttpMode: boolean
readonly host: string | undefined
readonly loadOAuthMetadata: () => Promise<unknown>
readonly port: number
readonly promptForApiKey: () => Promise<string>
Expand Down Expand Up @@ -78,6 +80,7 @@ export function createSocketMcpCliDeps(): SocketMcpCliDeps {
apiToken: getSocketApiToken(),
argv: process.argv,
envHttpMode: getMcpHttpMode(),
host: getMcpHost(),
loadOAuthMetadata,
port: getMcpPort(),
promptForApiKey: getApiKeyInteractively,
Expand Down Expand Up @@ -215,7 +218,7 @@ export async function runSocketMcpCli(deps: SocketMcpCliDeps): Promise<number> {
tracesSampleRate: deps.sentryTracesSampleRate,
})
}
deps.startHttpServer(deps.port)
deps.startHttpServer(deps.port, deps.host)
return 0
}

Expand Down
10 changes: 8 additions & 2 deletions lib/env.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* the catalog-pinned `lib@5.28.0`. The functions fall into
* two groups:
*
* 1. mcp-specific (MCP_HTTP_MODE, MCP_PORT, TRUST_PROXY) — these will never live
* in the canonical socket-lib env surface; they belong here.
* 1. mcp-specific (MCP_HTTP_MODE, MCP_HOST, MCP_PORT, TRUST_PROXY) — these will
* never live in the canonical socket-lib env surface; they belong here.
* 2. naming drift (`getSocketApiUrl` → `getSocketApiBaseUrl` in lib@5.28+) and
* OAuth getters that haven't shipped upstream yet — re-exports / shims
* that keep the mcp call sites stable until lib catches up. When lib
Expand Down Expand Up @@ -49,6 +49,12 @@ export function getMcpPort(): number {
return envInt('MCP_PORT') ?? 3000
}

// Unset keeps Node's default of listening on every interface, which deployed
// servers rely on. Set it (for example to 127.0.0.1) to bind one address.
export function getMcpHost(): string | undefined {
return envString('MCP_HOST')
}

// API URL — bridge for naming drift. lib@5.28.0 exposes
// `getSocketApiBaseUrl`; older mcp code asks for `getSocketApiUrl`.
// Both names resolve to the same value (SOCKET_API_BASE_URL or its
Expand Down
11 changes: 8 additions & 3 deletions lib/http-server.mts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export async function routeRequest(
// Boot the HTTP MCP server: build the MCP handler, create the Node HTTP
// server, route requests through `routeRequest`, listen, and log the start
// banner.
export function startHttpServer(port: number): void {
export function startHttpServer(port: number, host?: string): void {
logger.info(`Starting HTTP server on port ${port}`)

// One handler for the process. It calls `createConfiguredServer` per
Expand All @@ -389,7 +389,7 @@ export function startHttpServer(port: number): void {
)
})

httpServer.listen(port, () => {
const onListening = () => {
const address = httpServer.address()
if (typeof address === 'object' && address !== null) {
listeningPort = address.port
Expand All @@ -398,5 +398,10 @@ export function startHttpServer(port: number): void {
`Socket MCP HTTP server version ${VERSION} started successfully on port ${listeningPort}`,
)
logger.info(`Connect to: http://localhost:${listeningPort}/`)
})
}
if (host === undefined) {
httpServer.listen(port, onListening)
} else {
httpServer.listen(port, host, onListening)
}
}
Loading
Loading