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
@@ -2,6 +2,14 @@ name: Build Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: >
|
||||
Optional explicit release semver (e.g. 2.1.0). Must be greater than the
|
||||
version currently published to npm. Leave empty to bump patch from package.json.
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
@@ -40,9 +48,37 @@ jobs:
|
||||
|
||||
- name: Bump version
|
||||
id: bump-version
|
||||
env:
|
||||
EXPLICIT_VERSION: ${{ inputs.version }}
|
||||
run: |
|
||||
TAG=$(npm version patch --no-git-tag-version)
|
||||
VERSION=${TAG#v}
|
||||
set -euo pipefail
|
||||
PKG=$(node -p "require('./package.json').name")
|
||||
PKG_JSON_VERSION=$(node -p "require('./package.json').version")
|
||||
EXPLICIT_RAW=$(printf '%s' "${EXPLICIT_VERSION:-}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||
|
||||
if [ -z "$EXPLICIT_RAW" ]; then
|
||||
TAG=$(npm version patch --no-git-tag-version)
|
||||
VERSION=${TAG#v}
|
||||
else
|
||||
NPM_LATEST=$(npm view "$PKG" version) || {
|
||||
printf 'Package name (raw): %q\n' "$PKG" >&2
|
||||
echo "::error::Could not read the published version for comparison from npm (see log for package name)."
|
||||
exit 1
|
||||
}
|
||||
CLEANED=$(node -e "const semver=require('semver');const c=semver.clean(process.argv[1]);if(!c){process.exit(1)};process.stdout.write(c)" "$EXPLICIT_RAW") || {
|
||||
printf 'Received explicit version input (raw): %q\n' "$EXPLICIT_RAW" >&2
|
||||
echo "::error::Invalid semver for explicit version (see log for raw value)."
|
||||
exit 1
|
||||
}
|
||||
node -e "const semver=require('semver');const exp=process.argv[1];const latest=process.argv[2];const pkg=process.argv[3];\
|
||||
if(!semver.gt(exp,latest)){console.error('Explicit version',exp,'must be greater than npm latest',latest);process.exit(1);}\
|
||||
if(semver.lt(exp,pkg)){console.error('Explicit version',exp,'must not be less than package.json version',pkg);process.exit(1);}" \
|
||||
"$CLEANED" "$NPM_LATEST" "$PKG_JSON_VERSION"
|
||||
npm version "$CLEANED" --no-git-tag-version --allow-same-version
|
||||
VERSION="$CLEANED"
|
||||
TAG="v${VERSION}"
|
||||
fi
|
||||
|
||||
jq --arg v "$VERSION" '(.version,.packages[].version) = $v' server.json > tmp && mv tmp server.json
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/node_modules
|
||||
/dist
|
||||
.env
|
||||
.smithery
|
||||
@@ -196,14 +196,6 @@ Options:
|
||||
|
||||
## Installation
|
||||
|
||||
### Installing via Smithery
|
||||
|
||||
To install Brave Search automatically via [Smithery](https://smithery.ai/server/brave):
|
||||
|
||||
```bash
|
||||
npx -y @smithery/cli install brave
|
||||
```
|
||||
|
||||
### Usage with Claude Desktop
|
||||
|
||||
Add this to your `claude_desktop_config.json`:
|
||||
@@ -371,11 +363,6 @@ npx @modelcontextprotocol/inspector node dist/index.js
|
||||
|
||||
STDIO is the default mode. For HTTP mode testing, add `--transport http` 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
|
||||
|
||||
- `npm run build`: Build the TypeScript project
|
||||
@@ -386,8 +373,6 @@ STDIO is the default mode. For HTTP mode testing, add `--transport http` to the
|
||||
|
||||
- `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
|
||||
|
||||
|
||||
Generated
+96
-2921
File diff suppressed because it is too large.
Load diff
+1
-7
@@ -27,8 +27,6 @@
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc && shx chmod +x dist/*.js",
|
||||
"smithery:build": "smithery build",
|
||||
"smithery:dev": "smithery dev",
|
||||
"prepare": "npm run format && npm run build",
|
||||
"watch": "tsc --watch",
|
||||
"format": "prettier --write \"src/**/*.ts\"",
|
||||
@@ -45,15 +43,11 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "5.0.6",
|
||||
"@smithery/cli": "2.2.1",
|
||||
"@types/node": "24.10.13",
|
||||
"prettier": "3.8.1",
|
||||
"semver": "7.7.3",
|
||||
"shx": "0.4.0",
|
||||
"tsx": "4.21.0",
|
||||
"typescript": "5.9.3"
|
||||
},
|
||||
"overrides": {
|
||||
"formdata-node": "6.0.3",
|
||||
"tmp": "0.2.5"
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
runtime: "typescript"
|
||||
@@ -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