feat(core): expose MCP server title from serverInfo (#58950)

Co-authored-by: vimtor <36263538+vimtor@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot]
2026-10-25 11:02:29 +00:00
committed by GitHub
Unverified
parent 7a83c69fe1
commit 53f83e77fc
6 changed files with 22 additions and 4 deletions
+1
View File
@@ -717,6 +717,7 @@ export type IntegrationCommandAttempt = { attemptID: IntegrationAttemptID; time:
export type McpServer = {
name: string
status: McpStatusConnected | McpStatusPending | McpStatusDisabled | McpStatusFailed | McpStatusNeedsAuth
title?: string
integrationID?: IntegrationID
}
+3
View File
@@ -124,6 +124,8 @@ export interface ElicitationHandler {
export interface Connection {
/** True when the connection negotiated revision 2026-07-28 or later; false is the initialize handshake. */
readonly modern: boolean
/** Display title from `serverInfo.title`, when the server provides one. */
readonly title: string | undefined
readonly instructions: string | undefined
readonly tools: () => Effect.Effect<Tool[], Error>
readonly prompts: () => Effect.Effect<Prompt[], Error>
@@ -385,6 +387,7 @@ export const connect = Effect.fnUntraced(function* (
// Annotated rather than `satisfies`: the inferred SDK types are cyclic, so declaration emit needs the named type.
const connection: Connection = {
modern: client.getProtocolEra() === "modern",
title: client.getServerVersion()?.title?.trim() || undefined,
instructions: client.getInstructions()?.trim() || undefined,
tools: () =>
advertised("tools")
+8 -1
View File
@@ -759,7 +759,14 @@ export const layer = (options?: Options) =>
servers: Effect.fn("MCP.servers")(function* () {
return Array.from(entries)
.toSorted(([a], [b]) => a.localeCompare(b))
.map(([name, entry]): ServerInfo => ({ name, status: entry.status, integrationID: entry.integrationID }))
.map(
([name, entry]): ServerInfo => ({
name,
status: entry.status,
title: entry.client?.title,
integrationID: entry.integrationID,
}),
)
}),
add: Effect.fn("MCP.add")(function* (server, config) {
const name = ServerName.make(server)
+5 -3
View File
@@ -139,7 +139,7 @@ function resourceServer(
// still carry the previous session id are then unknown to the new transport.
const server = () => {
const protocol = new Server(
{ name: "mcp-resources", version: "1.0.0" },
{ name: "mcp-resources", title: "MCP Resources", version: "1.0.0" },
{
capabilities: {
tools: {},
@@ -1148,8 +1148,9 @@ test("reconnects and retries a tool call after the MCP session expires", async (
expect(server.state.toolCalls.map((call) => call.arguments)).toEqual([{ n: 1 }, { n: 2 }])
expect(server.state.initializations).toBe(2)
expect(server.state.sessions).toHaveLength(2)
expect((yield* service.servers()).find((entry) => entry.name === "resources")?.status).toEqual({
status: "connected",
expect((yield* service.servers()).find((entry) => entry.name === "resources")).toMatchObject({
status: { status: "connected" },
title: "MCP Resources",
})
}).pipe(Effect.provide(resourceMcpLayer(server.url)))
}),
@@ -1175,6 +1176,7 @@ describe.each([
)
expect(connection.modern).toBe(era === "modern")
expect(connection.title).toBe("MCP Resources")
expect(connection.instructions).toBe("Use the resources tools.")
expect((yield* connection.tools()).map((tool) => tool.name)).toEqual(["echo"])
expect((yield* connection.prompts()).map((prompt) => prompt.name)).toEqual(["greet"])
+3
View File
@@ -17376,6 +17376,9 @@
}
]
},
"title": {
"type": "string"
},
"integrationID": {
"$ref": "#/components/schemas/Integration.ID"
}
+2
View File
@@ -91,6 +91,8 @@ export interface Server extends Schema.Schema.Type<typeof Server> {}
export const Server = Schema.Struct({
name: Schema.String,
status: Status,
// Display title from the connected server's `serverInfo.title`; absent while disconnected or when not provided.
title: optional(Schema.String),
// Set for remote servers registered as OAuth integrations; lets clients act on the right integration
// without matching by name, which could collide with provider or plugin integrations.
integrationID: optional(IntegrationID),