Commit Graph
59 Commits
Author SHA1 Message Date
Daniel SamsonandClaude Haiku 4.5 01aebf9e02 fix: bind HTTP server to 0.0.0.0 instead of 127.0.0.1 for external access
Build and Push Docker Image / build (push) Successful in 21s
The MCP server was only listening on localhost (127.0.0.1), making it
unreachable from the Kubernetes service. Changed default host binding to
0.0.0.0 to accept traffic from all interfaces, allowing ingress routing.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-10-19 18:54:08 +01:00
Sampson 50cb919200 chore: remove dead code and fix HTTP port-conflict startup (#351)
* chore: remove dead code and fix HTTP port-conflict startup

- drop unused helpers, constants, schemas, and duplicated types
- exit non-zero when the HTTP port is already in use
- add stdio and port-conflict tests
- clean dist on build, add serve:http, fix inspector:http for Inspector v2

* test: harden port-conflict test; drop unreachable listen guard

- pin the child's host so BRAVE_MCP_HOST cannot bypass the conflict
- bound the exit wait and reject spawn errors
- remove the address() guard; 'listening' does not fire on a failed bind
2026-09-17 07:45:23 -07:00
SreeCharan Desu 4f7e4ea654 docs: stop telling agents image search has an offset (#348)
count's schema said to combine with offset for pagination, but the
image api has no offset at all — you just raise count (max 200). agents
were inventing a param that never existed.
2026-09-09 18:14:55 -05:00
Sampson e8b62148ad fix: advertise tool schemas as JSON Schema 2020-12 (#335)
* refactor(tools): pass Zod schemas to registerTool instead of raw shapes

registerTool accepts either a ZodObject or a raw shape, and passing the
schema itself keeps each tool definition closer to how its schema is
declared. The advertised JSON Schema is unchanged either way.

* fix(server): advertise tool schemas as JSON Schema 2020-12

The SDK converts our Zod schemas on every tools/list with a hardcoded
draft-07 target: mcp.js calls toJsonSchemaCompat() without a `target`, and
mapMiniTarget(undefined) falls back to 'draft-7'. No registerTool option
overrides it, so every schema we advertised declared draft-07.

Clients that validate against 2020-12 reject those definitions outright,
which takes down the whole tool list rather than a single tool. Separately,
brave_place_search's coordinates tuple emitted draft-07's array-form
`items`, which is invalid under 2020-12 where positional validation moved
to `prefixItems`.

SEP-1613 §5 requires servers to generate 2020-12 by default, so re-emit the
schemas on the tools/list response. Each correction is conditional, so this
decays to a no-op once the SDK emits 2020-12 itself.

Refs: https://github.com/modelcontextprotocol/typescript-sdk/issues/2084

* test(server): assert advertised schemas are valid JSON Schema 2020-12

Compile every tool's inputSchema and outputSchema from a real tools/list
response with a 2020-12 validator. This runs against the wire format rather
than our Zod definitions because the SDK performs the conversion itself: the
Zod schemas can be correct while the advertised JSON Schema is not.

Compiling resolves whichever dialect a schema declares, so a single check
covers both failure modes - a draft-07 declaration, and keywords that are
invalid under 2020-12. The SDK's own default client validator is Ajv
draft-07 with schema validation disabled, so it accepts output that 2020-12
clients reject; add ajv as a devDependency to check the dialect explicitly.
2026-08-20 10:41:28 -05:00
Sampson 937e85a61f test: consolidate MCP client/fetch-stub setup into useTestClient helper (#333) 2026-08-11 15:13:10 -05:00
Sampson dcd370b2a0 test: assert structuredContent and cover tool error paths 2026-08-11 13:24:52 -05:00
Sampson 71e05d1258 fix: handle absent current-day hours and multi-interval days in local search 2026-08-11 13:24:52 -05:00
Sampson 896ac6acd3 test: add MCP call tests for each search tool 2026-08-11 13:24:52 -05:00
Sampson 38d703263d test: add in-memory MCP client/server test harness 2026-08-11 13:24:52 -05:00
Sampson 576bd312d7 feat(http): hardens rebinding defenses (#317) 2026-07-18 14:18:54 -05:00
Sampson fd28e3e7b3 feat(config): support reading Brave API key from a file (#313)
* feat: support reading Brave API key from a file
* chore: add secret file template and gitignore local keys
* docs: document optional Docker Compose secrets workflow
* fix: trim whitespace API keys and exclude secrets from Docker build
* docs: clarify container paths for BRAVE_API_KEY_FILE
* test: cover API key file config and expand Docker build context ignores
* test: isolate getOptions tests from local env vars
* docs: clarify optional use of BRAVE_API_KEY_FILE
* docs: document BRAVE_API_KEY_FILE in AWS Marketplace catalog template
2026-06-24 13:53:51 -05:00
Sampson e3f77ced06 fix: http port validation (#312)
* fix: validate and parse HTTP port as integer

Commander leaves --port as a string, so invalid values like abc previously
passed numeric range checks. Parse ports strictly before starting HTTP transport.

* test: add parsePort unit tests and npm test script

Introduce node:test coverage for HTTP port parsing edge cases using the
existing tsx dev dependency.

* docs: correct README port default and image search description

Align BRAVE_MCP_PORT default with runtime behavior (8080) and remove the
outdated v1.x base64 image search note.
2026-06-24 07:58:51 -05:00
Sampson 42e1861f64 improvements to place_search support (#291)
Improves place_search schemas for better documentation. Avoids double-validation by deferring to MCP SDK for validation of response against outputSchema.
2026-05-03 17:16:16 -05:00
Sampson a48cf65c9d adds support for explicit version (#289) 2026-05-03 16:41:42 -05:00
Sampson cb52cbb03b introduces support for place search endpoint (#288) 2026-04-29 08:16:23 -05:00
Sampson 215e01252a improve header set construction 2026-04-25 19:48:07 -05:00
Sampson c7d2d14ef2 improves Goggles handling across project 2026-04-25 19:38:23 -05:00
Sampson e878c58a71 introduces support for newer LLM Context endpoint 2026-04-25 18:49:53 -05:00
Sampson 7861c9b734 omit result_filter while summarizing (#286)
Resolves #272
2026-04-23 10:03:16 -05:00
Sampson d4e9de74cc fixes freshness parsing (#285)
resolves #273
2026-04-22 09:14:30 -05:00
Sampson ae86cdc13f uses refined, proper tool list in state (#284) 2026-04-22 09:05:00 -05:00
Sampson 4476f5fa44 drop empty strings from tool config arrays 2026-01-28 19:44:04 -06:00
Sampson 3e260407f6 trims values before checking lengths 2026-01-28 12:58:01 -06:00
SampsonandHarold Spencer Jr. dd16a2e084 adds optional stateless configuration (#222)
* optional statelessness

* Update config.ts

* Update docker-compose.yml

* Update documentation

---------

Co-authored-by: Harold Spencer Jr. <hspencer@brave.com>
2026-01-25 22:14:07 -08:00
renovate[bot]andSampson 387eb1019e chore(deps): update dependency @smithery/cli to v2 (#202)
* chore(deps): update dependency @smithery/cli to v2
* updates Zod to v4 and Smithery to v2

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Sampson <jjdsampson@gmail.com>
2026-01-02 12:28:39 -06:00
copilot-swe-agent[bot]andmihaiplesa fc2d7144f0 fix: use readonly tuple for z.enum loggingLevel in src/config.ts to satisfy TypeScript and Zod
Co-authored-by: mihaiplesa <907672+mihaiplesa@users.noreply.github.com>
2025-12-03 17:47:39 +00:00
Sampson d9e509da6f fix(config): Defer retrieval of tool names
No longer attempts to calculate tool names as module-load time, but instead defers it until the values are needed. Additionally, this change updates the schema to support optional tool exposure when using smithery.ai.
2025-09-10 14:21:57 -05:00
Sampson 69eb8c9354 chore(logging): removes custom handling
With the release of version 1.17.5 of the SDK, servers no longer need to have their own custom handler for the SetLevelRequestSchema. See https://github.com/modelcontextprotocol/typescript-sdk/releases/tag/1.17.5.
2025-09-10 10:45:53 -05:00
Sampson 9f87c8bb93 feat(tools): implements optional tool exposure (#68)
Allows administrators to specify either a whitelist or a blacklist for determining which tools are desired. This work introduces new command-line arguments `--enabled-tools` and `--disabled-tools`, which cannot be used together. Likewise, this work also considers environment variables `BRAVE_MCP_ENABLED_TOOLS` and `BRAVE_MCP_DISABLED_TOOLS` as another means of communicating desired or undesired tools. See https://github.com/brave/brave-search-mcp-server/issues/62 for more on the motivation behind this feature.
2025-09-10 09:03:58 -05:00
Sampson 0bca1a42b3 sets stdio as the default transport
This is a breaking change, requiring a new major release of the server.

Resolves https://github.com/brave/brave-search-mcp-server/issues/63
2025-09-09 09:46:50 -05:00
Sampson 4fb81fb605 improve response structure of image tool (#52)
Tool now more closely resembles the documented response shape of the image API endpoint. This tool also no longer preemptively loads base64-encoded image data. The images tool now uses a structured content response. Following the suggestion in https://modelcontextprotocol.io/specification/2025-06-18/server/tools#output-schema, we also provide an Output Schema, enabling clients to validate the response. As a result of this work, the Images tool requires a slightly different registration approach. For this reason, registration can now be handled via a local "register" method in each tool module. When tools were registered externally in a for-loop, the type system was unable to infer the shape of each tool due to the overloaded union (resulting from only the Image tool having an OutputSchema export).
2025-09-06 10:35:08 -05:00
Sampson 398e88ffb8 implement smithery.ai changes (#66)
- Modifies project slightly to support distribution via smithery.ai.
- Resolves https://github.com/brave/brave-search-mcp-server/issues/65
- Overrides outdated formdata-node
2025-09-05 12:59:40 -05:00
Sampson 943b176f2a defer access to config 2025-09-05 11:26:03 -05:00
Sampson 0d751f748e fixes goggle-list support (#57)
Multiple goggles cannot be passed in a single comma-separated list. This change repeats the goggles parameter when multiple goggle URLs are used.
2025-08-28 12:42:28 -05:00
Sampson b64b2fea18 single server per transport (#48)
resolves https://github.com/brave/brave-search-mcp-server/issues/47

- Updates SDK to 1.17.3
- Creates a single server instance per transport
- Removes unnecessary ClientLogger (tool execution methods have access to a sendNotification method if so desired)
- Other small syntactic cleanups
2025-08-18 10:37:19 -05:00
SampsonandCopilot 60adaebcda Apply suggestion from @Copilot
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-14 11:11:10 -05:00
SampsonandCopilot b8d1459d38 Apply suggestion from @Copilot
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-14 11:07:55 -05:00
SampsonandCopilot 5e2ddaea2a Update src/ClientLogger.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-14 10:41:15 -05:00
SampsonandCopilot d0ddbf0dd2 Update src/BraveAPI/index.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-14 10:41:00 -05:00
Sampson a94e4dadab feat: adds proper logging support 2025-08-14 09:33:58 -05:00
Sampson 8ad2521abc unify string parts 2025-08-14 09:33:58 -05:00
Jim Clark 727cab9668 quiet dotenv for stdio mode 2025-08-04 09:39:30 -07:00
Sampson 9c61acdb63 improves testing with dotenv and mcp-inspector 2025-07-24 20:18:10 -05:00
Dan Kiuna 7d2bf67e61 remove duplicate enum in result_filter 2025-07-24 17:01:22 -05:00
Sampson 05f66d611f removes session-id generation/deps (#16) 2025-07-11 11:43:01 -07:00
Sampson fff3ddf188 now with even less invocation 2025-07-08 19:25:43 -05:00
Sampson beab641192 adds /ping and /invocations endpoints 2025-07-08 15:35:48 -05:00
Sampson bb6c97876d introduces support for summarizer 2025-07-07 11:17:28 -05:00
Sampson 1ba80e2312 filename pattern consistency 2025-07-03 12:48:02 -05:00
Sampson 52113e3246 retrieve api key from config alone
improves api key management; no longer retrieving it in different ways from different parts of the application
2025-07-02 18:07:24 -05:00