feat(opencode): list deferred MCP servers
This commit is contained in:
parent
8e84d9663b
commit
9a90e14c90
4 changed files with 75 additions and 3 deletions
|
|
@ -5,6 +5,7 @@ import { ProjectV2 } from "@opencode-ai/core/project"
|
|||
import { SessionV1 } from "@opencode-ai/core/v1/session"
|
||||
import { ModelV2 } from "@opencode-ai/core/model"
|
||||
import { ProviderV2 } from "@opencode-ai/core/provider"
|
||||
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
|
||||
import { Agent } from "@/agent/agent"
|
||||
import { MCP } from "@/mcp"
|
||||
import { Permission } from "@/permission"
|
||||
|
|
@ -21,6 +22,7 @@ import { testEffect } from "../lib/effect"
|
|||
const model = ProviderTest.model()
|
||||
const sessionID = SessionID.make("ses_deferred-tools")
|
||||
const largeSchemaDescription = "analytics trends schema ".repeat(10_000)
|
||||
const mcpClient = new Client({ name: "test", version: "0.0.0" })
|
||||
const agent = {
|
||||
name: "build",
|
||||
mode: "primary",
|
||||
|
|
@ -70,7 +72,7 @@ const makeIt = (input: { flags: Parameters<typeof RuntimeFlags.layer>[0]; queryD
|
|||
testEffect(
|
||||
Layer.mergeAll(
|
||||
Layer.mock(MCP.Service, {
|
||||
clients: () => Effect.succeed({}),
|
||||
clients: () => Effect.succeed({ posthog: mcpClient }),
|
||||
tools: () =>
|
||||
Effect.succeed({
|
||||
posthog_query_trends: tool({
|
||||
|
|
@ -158,6 +160,15 @@ describe("session.tools", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
deferredIt.instance("lists deferred MCP servers in the system prompt", () =>
|
||||
Effect.gen(function* () {
|
||||
const prompt = yield* SessionTools.deferredSystemPrompt({ agent, session })
|
||||
|
||||
expect(prompt).toContain("Deferred MCP servers available through `search_deferred_tools`:")
|
||||
expect(prompt).toContain("- posthog: 2 tools")
|
||||
}),
|
||||
)
|
||||
|
||||
directIt.instance("keeps MCP tools direct when tool search is disabled", () =>
|
||||
Effect.gen(function* () {
|
||||
const tools = yield* resolveTools()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue