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,8 +1,21 @@
|
||||
import { LoggingLevel, LoggingLevelSchema } from '@modelcontextprotocol/sdk/types.js';
|
||||
import { Command } from 'commander';
|
||||
import dotenv from 'dotenv';
|
||||
import { z } from 'zod';
|
||||
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 = {
|
||||
transport: 'stdio' | 'http';
|
||||
port: number;
|
||||
@@ -86,4 +99,8 @@ export function getOptions(): Configuration | false {
|
||||
return options as Configuration;
|
||||
}
|
||||
|
||||
export function setOptions(options: SmitheryConfig) {
|
||||
return Object.assign(state, options);
|
||||
}
|
||||
|
||||
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 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(
|
||||
{
|
||||
version: pkg.version,
|
||||
|
||||
Reference in new issue
Block a user