Download web/src/lib/mcp-server-create.test.ts from SaylorTwift/hermes-agent: direct link, hf CLI and curl.
- Browser
- Download file 2.57 kB
-
https://huggingface.co/SaylorTwift/hermes-agent/resolve/main/web/src/lib/mcp-server-create.test.ts
- Command line
-
hf download hf://SaylorTwift/hermes-agent/web/src/lib/mcp-server-create.test.ts
-
curl -L -o mcp-server-create.test.ts https://huggingface.co/SaylorTwift/hermes-agent/resolve/main/web/src/lib/mcp-server-create.test.ts
2.57 kB
| import { describe, expect, it } from "vitest"; | |
| import { buildMcpServerCreate, emptyMcpServerDraft } from "./mcp-server-create"; | |
| describe("buildMcpServerCreate", () => { | |
| it("builds an HTTP Bearer request without stdio fields", () => { | |
| const server = buildMcpServerCreate({ | |
| ...emptyMcpServerDraft(), | |
| name: " Linear ", | |
| url: " https://mcp.linear.app/mcp ", | |
| httpAuth: "header", | |
| bearerToken: "Bearer secret-token", | |
| command: "ignored", | |
| args: "--ignored", | |
| env: "IGNORED=value", | |
| }); | |
| expect(server).toEqual({ | |
| name: "Linear", | |
| url: "https://mcp.linear.app/mcp", | |
| auth: "header", | |
| bearer_token: "Bearer secret-token", | |
| }); | |
| }); | |
| it("builds OAuth and unauthenticated HTTP requests without a token", () => { | |
| expect( | |
| buildMcpServerCreate({ | |
| ...emptyMcpServerDraft(), | |
| name: "oauth", | |
| url: "https://example.com/mcp", | |
| httpAuth: "oauth", | |
| }), | |
| ).toEqual({ | |
| name: "oauth", | |
| url: "https://example.com/mcp", | |
| auth: "oauth", | |
| }); | |
| expect( | |
| buildMcpServerCreate({ | |
| ...emptyMcpServerDraft(), | |
| name: "public", | |
| url: "https://example.com/mcp", | |
| }), | |
| ).toEqual({ | |
| name: "public", | |
| url: "https://example.com/mcp", | |
| }); | |
| }); | |
| it("parses stdio arguments and environment assignments", () => { | |
| const server = buildMcpServerCreate({ | |
| ...emptyMcpServerDraft(), | |
| name: "local", | |
| transport: "stdio", | |
| command: " uvx ", | |
| args: "mcp-server, --debug", | |
| env: "API_KEY=secret\nURL=https://example.com?a=b\nINVALID", | |
| }); | |
| expect(server).toEqual({ | |
| name: "local", | |
| command: "uvx", | |
| args: ["mcp-server", "--debug"], | |
| env: { | |
| API_KEY: "secret", | |
| URL: "https://example.com?a=b", | |
| }, | |
| }); | |
| }); | |
| it("rejects missing transport fields and Bearer tokens", () => { | |
| expect(() => buildMcpServerCreate(emptyMcpServerDraft())).toThrow( | |
| "Name required", | |
| ); | |
| expect(() => | |
| buildMcpServerCreate({ | |
| ...emptyMcpServerDraft(), | |
| name: "remote", | |
| }), | |
| ).toThrow("URL required"); | |
| expect(() => | |
| buildMcpServerCreate({ | |
| ...emptyMcpServerDraft(), | |
| name: "remote", | |
| url: "https://example.com/mcp", | |
| httpAuth: "header", | |
| }), | |
| ).toThrow("Bearer token required"); | |
| expect(() => | |
| buildMcpServerCreate({ | |
| ...emptyMcpServerDraft(), | |
| name: "local", | |
| transport: "stdio", | |
| }), | |
| ).toThrow("Command required"); | |
| }); | |
| }); | |