adds support for explicit version (#289)
This commit is contained in:
1 parent
cb52cbb03b
commit
a48cf65c9d
8 files changed
+136
-3010
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import { LoggingLevel, LoggingLevelSchema } from '@modelcontextprotocol/sdk/types.js';
|
||||
import { Command } from 'commander';
|
||||
import dotenv from 'dotenv';
|
||||
import { z } from 'zod';
|
||||
import tools from './tools/index.js';
|
||||
|
||||
dotenv.config({ debug: false, quiet: true });
|
||||
@@ -16,55 +15,6 @@ function parseToolNameList(value: string | string[] | undefined | null): string[
|
||||
.filter((t: string) => t.length > 0);
|
||||
}
|
||||
|
||||
// Config schema for Smithery.ai
|
||||
export const configSchema = z
|
||||
.object({
|
||||
braveApiKey: z
|
||||
.string()
|
||||
.describe('Your API key')
|
||||
.default(process.env.BRAVE_API_KEY ?? ''),
|
||||
enabledTools: z
|
||||
.array(z.string())
|
||||
.describe('Enforces a tool whitelist (cannot be used with disabledTools)')
|
||||
.optional(),
|
||||
disabledTools: z
|
||||
.array(z.string())
|
||||
.describe('Enforces a tool blacklist (cannot be used with enabledTools)')
|
||||
.optional(),
|
||||
loggingLevel: z
|
||||
.enum([
|
||||
'debug',
|
||||
'error',
|
||||
'info',
|
||||
'notice',
|
||||
'warning',
|
||||
'critical',
|
||||
'alert',
|
||||
'emergency',
|
||||
] as const)
|
||||
.default('info')
|
||||
.describe('Desired logging level')
|
||||
.optional(),
|
||||
stateless: z
|
||||
.boolean()
|
||||
.default(false)
|
||||
.describe('Whether the server should be stateless')
|
||||
.optional(),
|
||||
})
|
||||
.refine(
|
||||
(config) => {
|
||||
const enabledTools = parseToolNameList(config.enabledTools);
|
||||
const disabledTools = parseToolNameList(config.disabledTools);
|
||||
return enabledTools.length === 0 || disabledTools.length === 0;
|
||||
},
|
||||
{
|
||||
message: 'enabledTools and disabledTools cannot be used together',
|
||||
path: ['enabledTools', 'disabledTools'],
|
||||
}
|
||||
);
|
||||
|
||||
export type SmitheryConfig = z.infer<typeof configSchema>;
|
||||
|
||||
type Configuration = {
|
||||
transport: 'stdio' | 'http';
|
||||
port: number;
|
||||
@@ -205,8 +155,4 @@ export function getOptions(): Configuration | false {
|
||||
return options as Configuration;
|
||||
}
|
||||
|
||||
export function setOptions(options: SmitheryConfig) {
|
||||
return Object.assign(state, options);
|
||||
}
|
||||
|
||||
export default state;
|
||||
+1
-9
@@ -2,16 +2,8 @@ import tools from './tools/index.js';
|
||||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import pkg from '../package.json' with { type: 'json' };
|
||||
import { isToolPermittedByUser } from './config.js';
|
||||
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);
|
||||
|
||||
export default function createMcpServer(): McpServer {
|
||||
const mcpServer = new McpServer(
|
||||
{
|
||||
version: pkg.version,
|
||||
|
||||
Reference in new issue
Block a user