Add configurable seal-home MCP toggle
This commit is contained in:
1 parent
883798b157
commit
8be627e1c6
9 files changed
+164
-79
No files matched your search
+34
-20
@@ -15,8 +15,15 @@ const pluginRoot = serverEntryFile.includes("/dist/mcp/") || serverEntryFile.inc
|
||||
: dirname(dirname(serverEntryFile));
|
||||
|
||||
export const SEAL_CLI_TOOL_NAME = "seal_cli";
|
||||
export const SEAL_MCP_ENABLED_ENV = "SEAL_HOME_MCP_ENABLED";
|
||||
|
||||
export function createServer() {
|
||||
export function resolveMcpEnabled(value = process.env[SEAL_MCP_ENABLED_ENV]): boolean {
|
||||
if (value === undefined) return false;
|
||||
return ["1", "true", "yes", "on"].includes(value.trim().toLowerCase());
|
||||
}
|
||||
|
||||
export function createServer(options: { enableCli?: boolean } = {}) {
|
||||
const enableCli = options.enableCli ?? true;
|
||||
const server = new Server(
|
||||
{
|
||||
name: "seal-home",
|
||||
@@ -30,26 +37,28 @@ export function createServer() {
|
||||
);
|
||||
|
||||
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
||||
tools: [
|
||||
{
|
||||
name: SEAL_CLI_TOOL_NAME,
|
||||
description: "Run seal-home CLI commands. See the seal-home skill for command reference.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
command: {
|
||||
type: "string",
|
||||
description: "A seal-home CLI command, with or without the leading 'seal-home'."
|
||||
tools: enableCli
|
||||
? [
|
||||
{
|
||||
name: SEAL_CLI_TOOL_NAME,
|
||||
description: "Run seal-home CLI commands. See the seal-home skill for command reference.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
command: {
|
||||
type: "string",
|
||||
description: "A seal-home CLI command, with or without the leading 'seal-home'."
|
||||
}
|
||||
},
|
||||
required: ["command"],
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
required: ["command"],
|
||||
additionalProperties: false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
: []
|
||||
}));
|
||||
|
||||
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
if (enableCli) server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
const args = request.params.arguments;
|
||||
const command = args && typeof args.command === "string" ? args.command : undefined;
|
||||
if (!command?.trim()) {
|
||||
@@ -90,9 +99,14 @@ export function createServer() {
|
||||
}
|
||||
|
||||
export async function startServer() {
|
||||
const server = createServer();
|
||||
const enableCli = resolveMcpEnabled();
|
||||
const server = createServer({ enableCli });
|
||||
await server.connect(new StdioServerTransport());
|
||||
console.error("seal-home MCP server running on stdio");
|
||||
console.error(
|
||||
enableCli
|
||||
? "seal-home MCP server running on stdio"
|
||||
: "seal-home MCP server connected with seal_cli disabled by configuration"
|
||||
);
|
||||
}
|
||||
|
||||
export function tokenizeCommand(command: string): string[] {
|
||||
|
||||
Reference in new issue
Block a user