Add seal-home ZCode plugin packaging
This commit is contained in:
1 parent
0959cef1cc
commit
38610d3573
24 files changed
+31884
-1655
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
||||
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
||||
import { createServer, SEAL_CLI_TOOL_NAME, tokenizeCommand } from "./server.js";
|
||||
|
||||
describe("seal-home MCP server", () => {
|
||||
test("tokenizes quoted JSON without invoking a shell", () => {
|
||||
expect(tokenizeCommand(
|
||||
`seal-home tool seal_approval_search --json '{"keywords":["差旅 发票"]}' --corp corp-a`
|
||||
)).toEqual([
|
||||
"seal-home",
|
||||
"tool",
|
||||
"seal_approval_search",
|
||||
"--json",
|
||||
'{"keywords":["差旅 发票"]}',
|
||||
"--corp",
|
||||
"corp-a"
|
||||
]);
|
||||
});
|
||||
|
||||
test("advertises one tool and executes version through the CLI runner", async () => {
|
||||
const server = createServer();
|
||||
const client = new Client({ name: "seal-home-test", version: "1.0.0" });
|
||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||
|
||||
try {
|
||||
await Promise.all([
|
||||
server.connect(serverTransport),
|
||||
client.connect(clientTransport)
|
||||
]);
|
||||
|
||||
const listed = await client.listTools();
|
||||
expect(listed.tools).toHaveLength(1);
|
||||
expect(listed.tools[0]?.name).toBe(SEAL_CLI_TOOL_NAME);
|
||||
expect(listed.tools[0]?.inputSchema).toMatchObject({
|
||||
type: "object",
|
||||
required: ["command"]
|
||||
});
|
||||
|
||||
const result = await client.callTool({
|
||||
name: SEAL_CLI_TOOL_NAME,
|
||||
arguments: { command: "seal-home version" }
|
||||
});
|
||||
const content = result.content as Array<{ type: "text"; text: string }>;
|
||||
const text = content[0];
|
||||
expect(result.isError).not.toBe(true);
|
||||
expect(text?.type).toBe("text");
|
||||
if (text?.type === "text") {
|
||||
expect(JSON.parse(text.text)).toMatchObject({ name: "seal-home" });
|
||||
}
|
||||
|
||||
const invalid = await client.callTool({
|
||||
name: SEAL_CLI_TOOL_NAME,
|
||||
arguments: { command: "not-a-command" }
|
||||
});
|
||||
expect(invalid.isError).toBe(true);
|
||||
const invalidContent = invalid.content as Array<{ type: "text"; text: string }>;
|
||||
const errorText = invalidContent[0];
|
||||
expect(errorText?.type).toBe("text");
|
||||
if (errorText?.type === "text") {
|
||||
expect(errorText.text).toContain("Unknown command: not-a-command");
|
||||
}
|
||||
} finally {
|
||||
await Promise.allSettled([client.close(), server.close()]);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user