File size: 1,868 Bytes
5f40163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import type {
  AgentServerMCPOAuthStatusResponse,
  AgentServerMCPStartOAuthResponse,
  AgentServerMCPTestResponse,
  AgentServerMCPToolCall,
  AgentServerMCPToolCallResult,
  MCPTestFailureKind,
} from "@openhands/typescript-client";
import type { MCPAuthCredential, MCPOAuthState } from "./mcp-auth";

export type MCPServerType = "sse" | "stdio" | "shttp";

export interface MCPServerConfig {
  id: string;
  type: MCPServerType;
  name?: string;
  url?: string;
  headers?: Record<string, string>;
  timeout?: number;
  command?: string;
  args?: string[];
  env?: Record<string, string>;
  auth?: MCPAuthCredential;
  /**
   * Whether the agent may use this server. Absent means enabled — only an
   * explicit `false` disables, so existing configs stay untouched.
   */
  enabled?: boolean;
}

export type MCPTestToolCall = AgentServerMCPToolCall;
export type MCPTestToolResult = AgentServerMCPToolCallResult;

export type ExtendedMCPTestFailureKind = MCPTestFailureKind | "credentials";

type GeneratedMCPTestSuccess = Extract<
  AgentServerMCPTestResponse,
  { ok?: true }
>;
type GeneratedMCPTestFailure = Extract<
  AgentServerMCPTestResponse,
  { error: string }
>;

export type ExtendedMCPTestSuccess = Omit<
  GeneratedMCPTestSuccess,
  "ok" | "tools" | "oauth_state"
> & {
  ok: true;
  tools: string[];
  tool_result?: MCPTestToolResult | null;
  oauth_state?: MCPOAuthState | null;
};

export type ExtendedMCPTestFailure = Omit<
  GeneratedMCPTestFailure,
  "ok" | "error_kind"
> & {
  ok: false;
  error_kind: ExtendedMCPTestFailureKind;
};

export type ExtendedMCPTestResponse =
  | ExtendedMCPTestSuccess
  | ExtendedMCPTestFailure;

export type MCPOAuthStartResponse = AgentServerMCPStartOAuthResponse;
export type MCPOAuthStatusResponse = Omit<
  AgentServerMCPOAuthStatusResponse,
  "oauth_state"
> & {
  oauth_state?: MCPOAuthState | null;
};