d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
121 lines
3.1 KiB
TypeScript
121 lines
3.1 KiB
TypeScript
import { isEqual, omit } from 'es-toolkit'
|
|
import type { McpToolSchema, StoredMcpToolReference } from '@/lib/mcp/types'
|
|
|
|
export type McpToolIssueType =
|
|
| 'server_not_found'
|
|
| 'server_error'
|
|
| 'tool_not_found'
|
|
| 'schema_changed'
|
|
| 'url_changed'
|
|
|
|
export interface McpToolIssue {
|
|
type: McpToolIssueType
|
|
message: string
|
|
}
|
|
|
|
export interface ServerState {
|
|
id: string
|
|
url?: string
|
|
connectionStatus?: 'connected' | 'disconnected' | 'error'
|
|
lastError?: string
|
|
}
|
|
|
|
export interface DiscoveredTool {
|
|
serverId: string
|
|
name: string
|
|
inputSchema?: McpToolSchema
|
|
}
|
|
|
|
export function hasSchemaChanged(
|
|
storedSchema: McpToolSchema | undefined,
|
|
serverSchema: McpToolSchema | undefined
|
|
): boolean {
|
|
if (!storedSchema || !serverSchema) return false
|
|
|
|
const storedWithoutDesc = omit(storedSchema, ['description'])
|
|
const serverWithoutDesc = omit(serverSchema, ['description'])
|
|
|
|
return !isEqual(storedWithoutDesc, serverWithoutDesc)
|
|
}
|
|
|
|
/**
|
|
* Validates server-level connectivity for an MCP server.
|
|
* Checks: server existence, connection status, URL changes.
|
|
*/
|
|
export function getMcpServerIssue(
|
|
serverId: string,
|
|
serverUrl: string | undefined,
|
|
servers: ServerState[]
|
|
): McpToolIssue | null {
|
|
const server = servers.find((s) => s.id === serverId)
|
|
if (!server) {
|
|
return { type: 'server_not_found', message: 'Server not found' }
|
|
}
|
|
|
|
if (server.connectionStatus === 'error') {
|
|
return { type: 'server_error', message: server.lastError || 'Server connection error' }
|
|
}
|
|
if (server.connectionStatus !== 'connected') {
|
|
return { type: 'server_error', message: 'Server not connected' }
|
|
}
|
|
|
|
if (serverUrl && server.url && serverUrl !== server.url) {
|
|
return { type: 'url_changed', message: 'Server URL changed' }
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
export function getMcpToolIssue(
|
|
storedTool: StoredMcpToolReference,
|
|
servers: ServerState[],
|
|
discoveredTools: DiscoveredTool[]
|
|
): McpToolIssue | null {
|
|
const { serverId, serverUrl, toolName, schema } = storedTool
|
|
|
|
const serverIssue = getMcpServerIssue(serverId, serverUrl, servers)
|
|
if (serverIssue) return serverIssue
|
|
|
|
const serverTool = discoveredTools.find((t) => t.serverId === serverId && t.name === toolName)
|
|
if (!serverTool) {
|
|
return { type: 'tool_not_found', message: 'Tool not found on server' }
|
|
}
|
|
|
|
if (schema && serverTool.inputSchema) {
|
|
if (hasSchemaChanged(schema, serverTool.inputSchema)) {
|
|
return { type: 'schema_changed', message: 'Tool schema changed' }
|
|
}
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
export function getIssueBadgeLabel(issue: McpToolIssue): string {
|
|
switch (issue.type) {
|
|
case 'schema_changed':
|
|
case 'url_changed':
|
|
return 'stale'
|
|
default:
|
|
return 'unavailable'
|
|
}
|
|
}
|
|
|
|
export function getIssueBadgeVariant(issue: McpToolIssue): 'amber' | 'red' {
|
|
switch (issue.type) {
|
|
case 'schema_changed':
|
|
case 'url_changed':
|
|
return 'amber'
|
|
default:
|
|
return 'red'
|
|
}
|
|
}
|
|
|
|
export function isToolUnavailable(issue: McpToolIssue | null): boolean {
|
|
if (!issue) return false
|
|
return (
|
|
issue.type === 'server_not_found' ||
|
|
issue.type === 'server_error' ||
|
|
issue.type === 'tool_not_found'
|
|
)
|
|
}
|