mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-02 02:58:10 +02:00
Add MCP legacy tool parity coverage
This commit is contained in:
parent
c48927b7c5
commit
c40bd406f8
3 changed files with 77 additions and 18 deletions
|
|
@ -1,10 +1,22 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import * as Predicate from "effect/Predicate";
|
||||
import { createMcpServer } from "../server.js";
|
||||
import {
|
||||
makeTrustGraphMcpStdioLayer,
|
||||
runStdio,
|
||||
TrustGraphMcpToolkit,
|
||||
} from "../server-effect.js";
|
||||
|
||||
const clientMock = vi.hoisted(() => ({
|
||||
createTrustGraphSocket: vi.fn(() => ({
|
||||
close: vi.fn(),
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock("@trustgraph/client", () => ({
|
||||
createTrustGraphSocket: clientMock.createTrustGraphSocket,
|
||||
}));
|
||||
|
||||
const expectedToolNames = [
|
||||
"text_completion",
|
||||
"graph_rag",
|
||||
|
|
@ -31,11 +43,31 @@ const expectedToolNames = [
|
|||
"load_kg_core",
|
||||
];
|
||||
|
||||
const registeredToolNames = (value: unknown): Array<string> => {
|
||||
if (!Predicate.isObject(value) || !Predicate.hasProperty(value, "_registeredTools")) {
|
||||
return [];
|
||||
}
|
||||
return Predicate.isObject(value._registeredTools)
|
||||
? Object.keys(value._registeredTools)
|
||||
: [];
|
||||
};
|
||||
|
||||
describe("Effect MCP server", () => {
|
||||
it("keeps the canonical Effect toolkit names stable", () => {
|
||||
expect(Object.keys(TrustGraphMcpToolkit.tools)).toEqual(expectedToolNames);
|
||||
});
|
||||
|
||||
it("keeps legacy SDK stdio tools aligned with the Effect toolkit", () => {
|
||||
const { server, socket } = createMcpServer({
|
||||
gatewayUrl: "ws://localhost:8088/api/v1/rpc",
|
||||
user: "mcp-test",
|
||||
flowId: "default",
|
||||
});
|
||||
|
||||
expect(registeredToolNames(server)).toEqual(Object.keys(TrustGraphMcpToolkit.tools));
|
||||
expect(socket.close).toEqual(expect.any(Function));
|
||||
});
|
||||
|
||||
it("exposes an Effect stdio layer and process entrypoint", () => {
|
||||
expect(
|
||||
makeTrustGraphMcpStdioLayer({
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import {createTrustGraphSocket, type BaseApi, type Term} from "@trustgraph/clien
|
|||
import {Effect, Layer, ManagedRuntime} from "effect";
|
||||
import * as Predicate from "effect/Predicate";
|
||||
import * as S from "effect/Schema";
|
||||
import {z} from "zod";
|
||||
import * as z from "zod";
|
||||
import {loadTrustGraphMcpConfig} from "./server-effect.js";
|
||||
|
||||
interface ToolTextContent {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue