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
This commit is contained in:
1 parent
943b176f2a
commit
398e88ffb8
7 files changed
+2414
-1
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
/dist
|
/dist
|
||||||
.env
|
.env
|
||||||
|
.smithery
|
||||||
@@ -285,6 +285,11 @@ npx @modelcontextprotocol/inspector node dist/index.js
|
|||||||
|
|
||||||
For STDIO mode testing, add `--transport stdio` to the arguments in the Inspector UI.
|
For STDIO mode testing, add `--transport stdio` to the arguments in the Inspector UI.
|
||||||
|
|
||||||
|
### Testing via Smithery.AI
|
||||||
|
|
||||||
|
1. Establish and acquire a smithery.ai account and API key
|
||||||
|
2. Run `npm run install`, `npm run smithery:build`, and lastly `npm run smithery:dev` to begin testing
|
||||||
|
|
||||||
### Available Scripts
|
### Available Scripts
|
||||||
|
|
||||||
- `npm run build`: Build the TypeScript project
|
- `npm run build`: Build the TypeScript project
|
||||||
@@ -293,6 +298,11 @@ For STDIO mode testing, add `--transport stdio` to the arguments in the Inspecto
|
|||||||
- `npm run format:check`: Check code formatting
|
- `npm run format:check`: Check code formatting
|
||||||
- `npm run prepare`: Format and build (runs automatically on npm install)
|
- `npm run prepare`: Format and build (runs automatically on npm install)
|
||||||
|
|
||||||
|
- `npm run inspector`: Launch an instance of MCP Inspector
|
||||||
|
- `npm run inspector:stdio`: Launch a instance of MCP Inspector, configured for STDIO
|
||||||
|
- `npm run smithery:build`: Build the project for smithery.ai
|
||||||
|
- `npm run smithery:dev`: Launch the development environment for smithery.ai
|
||||||
|
|
||||||
### Docker Compose
|
### Docker Compose
|
||||||
|
|
||||||
For local development with Docker:
|
For local development with Docker:
|
||||||
|
|||||||
Generated
+2367
File diff suppressed because it is too large.
Load diff
@@ -17,6 +17,7 @@
|
|||||||
"url": "https://github.com/brave/brave-search-mcp-server.git"
|
"url": "https://github.com/brave/brave-search-mcp-server.git"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"module": "dist/server.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"brave-search-mcp-server": "dist/index.js"
|
"brave-search-mcp-server": "dist/index.js"
|
||||||
},
|
},
|
||||||
@@ -25,6 +26,8 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc && shx chmod +x dist/*.js",
|
"build": "tsc && shx chmod +x dist/*.js",
|
||||||
|
"smithery:build": "npx @smithery/cli build",
|
||||||
|
"smithery:dev": "npx @smithery/cli dev",
|
||||||
"prepare": "npm run format && npm run build",
|
"prepare": "npm run format && npm run build",
|
||||||
"watch": "tsc --watch",
|
"watch": "tsc --watch",
|
||||||
"format": "prettier --write \"src/**/*.ts\"",
|
"format": "prettier --write \"src/**/*.ts\"",
|
||||||
@@ -40,10 +43,15 @@
|
|||||||
"zod": "3.25.76"
|
"zod": "3.25.76"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@smithery/cli": "1.2.22",
|
||||||
"@types/express": "5.0.3",
|
"@types/express": "5.0.3",
|
||||||
"@types/node": "24.3.0",
|
"@types/node": "24.3.0",
|
||||||
"prettier": "3.6.2",
|
"prettier": "3.6.2",
|
||||||
"shx": "0.4.0",
|
"shx": "0.4.0",
|
||||||
|
"tsx": "4.20.5",
|
||||||
"typescript": "5.9.2"
|
"typescript": "5.9.2"
|
||||||
|
},
|
||||||
|
"overrides": {
|
||||||
|
"formdata-node": "6.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
runtime: "typescript"
|
||||||
@@ -1,8 +1,21 @@
|
|||||||
import { LoggingLevel, LoggingLevelSchema } from '@modelcontextprotocol/sdk/types.js';
|
import { LoggingLevel, LoggingLevelSchema } from '@modelcontextprotocol/sdk/types.js';
|
||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
|
import { z } from 'zod';
|
||||||
dotenv.config({ debug: false, quiet: true });
|
dotenv.config({ debug: false, quiet: true });
|
||||||
|
|
||||||
|
// Config schema for Smithery.ai
|
||||||
|
export const configSchema = z.object({
|
||||||
|
braveApiKey: z.string().describe('Your API key'),
|
||||||
|
loggingLevel: z
|
||||||
|
.enum(LoggingLevelSchema.options)
|
||||||
|
.default('info')
|
||||||
|
.describe('Desired logging level')
|
||||||
|
.optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type SmitheryConfig = z.infer<typeof configSchema>;
|
||||||
|
|
||||||
type Configuration = {
|
type Configuration = {
|
||||||
transport: 'stdio' | 'http';
|
transport: 'stdio' | 'http';
|
||||||
port: number;
|
port: number;
|
||||||
@@ -86,4 +99,8 @@ export function getOptions(): Configuration | false {
|
|||||||
return options as Configuration;
|
return options as Configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setOptions(options: SmitheryConfig) {
|
||||||
|
return Object.assign(state, options);
|
||||||
|
}
|
||||||
|
|
||||||
export default state;
|
export default state;
|
||||||
+10
-1
@@ -3,7 +3,16 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|||||||
import { SetLevelRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
import { SetLevelRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
||||||
import pkg from '../package.json' with { type: 'json' };
|
import pkg from '../package.json' with { type: 'json' };
|
||||||
|
|
||||||
export default function createMcpServer(): McpServer {
|
import { type SmitheryConfig, setOptions } from './config.js';
|
||||||
|
export { configSchema } from './config.js';
|
||||||
|
|
||||||
|
type CreateMcpServerOptions = {
|
||||||
|
config: SmitheryConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function createMcpServer(options?: CreateMcpServerOptions): McpServer {
|
||||||
|
if (options?.config) setOptions(options.config);
|
||||||
|
|
||||||
const mcpServer = new McpServer(
|
const mcpServer = new McpServer(
|
||||||
{
|
{
|
||||||
version: pkg.version,
|
version: pkg.version,
|
||||||
|
|||||||
Reference in new issue
Block a user