@mcpstack/agent-sdk 1.0.0-pr.18.bbb0c016bc21.17.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  Use MCP Stack agents in your app.
4
4
 
5
- AgentSDK is MCP Stack's first-party AG-UI client. Your app talks AG-UI to the agent; MCP Stack keeps server tools on MCP through Gateway, AuthGateway, budgets, logs, and permissions.
6
-
7
- This package has one public model for custom product integrations: `App Agent`.
5
+ This package now has one public model for custom product integrations: `App Agent`.
8
6
 
9
7
  ## Install
10
8
 
@@ -64,21 +62,21 @@ export function App() {
64
62
  return (
65
63
  <div style={{ height: 640 }}>
66
64
  <McpStackChat
67
- apiKey="mcpstack_pk_xxxx"
65
+ apiKey="mcpstack_sk_xxxx"
68
66
  agentId="ag_xxxxx"
69
67
  appSessionKey={session.id}
70
- userIdentity={{
71
- subject: session.user.id,
72
- email: session.user.email,
73
- organizationId: session.organizationId,
74
- }}
75
- auth={{
76
- mode: "app-token",
77
- getToken: () => session.getAccessToken(),
78
- }}
79
- mode="inline"
80
- title="Support Agent"
81
- />
68
+ userIdentity={{
69
+ subject: session.user.id,
70
+ email: session.user.email,
71
+ organizationId: session.organizationId,
72
+ }}
73
+ auth={{
74
+ mode: "app-token",
75
+ getToken: () => session.getAccessToken(),
76
+ }}
77
+ mode="inline"
78
+ title="Support Agent"
79
+ />
82
80
  </div>
83
81
  );
84
82
  }
@@ -91,7 +89,7 @@ import { useAppAgent } from "@mcpstack/agent-sdk/react";
91
89
 
92
90
  export function CustomAssistant() {
93
91
  const agent = useAppAgent({
94
- apiKey: "mcpstack_pk_xxxx",
92
+ apiKey: "mcpstack_sk_xxxx",
95
93
  agentId: "ag_xxxxx",
96
94
  appSessionKey: session.id,
97
95
  userIdentity: {
@@ -118,7 +116,7 @@ import { useAppAgent } from "@mcpstack/agent-sdk/react-native";
118
116
 
119
117
  export function AssistantShell() {
120
118
  const agent = useAppAgent({
121
- apiKey: "mcpstack_pk_xxxx",
119
+ apiKey: "mcpstack_sk_xxxx",
122
120
  agentId: "ag_xxxxx",
123
121
  appSessionKey: session.id,
124
122
  userIdentity: {
@@ -142,7 +140,7 @@ export function AssistantShell() {
142
140
  import { McpStackAgent } from "@mcpstack/agent-sdk";
143
141
 
144
142
  const agent = new McpStackAgent({
145
- apiKey: "mcpstack_pk_xxxx",
143
+ apiKey: "mcpstack_sk_xxxx",
146
144
  agentId: "ag_xxxxx",
147
145
  authSessionKey: session.id,
148
146
  });
@@ -160,7 +158,7 @@ Apps can tune the behavior without implementing their own VAD:
160
158
 
161
159
  ```ts
162
160
  const agent = new McpStackAgent({
163
- apiKey: "mcpstack_pk_xxxx",
161
+ apiKey: "mcpstack_sk_xxxx",
164
162
  agentId: "ag_xxxxx",
165
163
  audioInput: {
166
164
  turnDetection: {
@@ -177,7 +175,7 @@ const agent = new McpStackAgent({
177
175
 
178
176
  ### `apiKey`
179
177
 
180
- Your MCP Stack public agent key, usually an `mcpstack_pk_*` embed key scoped to the agent and allowed browser origins.
178
+ Your MCP Stack API key.
181
179
 
182
180
  ### `agentId`
183
181
 
@@ -217,40 +215,19 @@ auth: {
217
215
  auth library refreshes tokens, read from that current session source rather than
218
216
  capturing a token from the first render.
219
217
 
220
- The SDK forwards that app token with the AG-UI run. When the agent needs a server MCP tool, MCP Stack exchanges the app token at Gateway for an MCP-facing token without OAuth client registration. External MCP clients can still use the same Gateway-backed server through standard OAuth discovery, registration, and authorization.
218
+ The SDK exchanges that app token at Gateway for an MCP-facing token without
219
+ OAuth client registration. External MCP clients can still use the same
220
+ Gateway-backed server through standard OAuth discovery, registration, and
221
+ authorization.
221
222
 
222
223
  ### `clientTools`
223
224
 
224
225
  App-owned functions the agent can call locally for UI work or host orchestration.
225
226
 
226
- AgentSDK sends these as AG-UI frontend tool schemas. They run in your app and should stay focused on route changes, current-screen reads, drafting, filtering, approvals, and other local UI work. Use server MCP tools for authoritative backend reads and writes.
227
-
228
227
  ### `appContext`
229
228
 
230
229
  Extra host context or policy instructions for the agent.
231
230
 
232
- ## Protocol boundary
233
-
234
- AgentSDK uses AG-UI for agent turns:
235
-
236
- ```text
237
- AgentSDK / custom AG-UI frontend
238
- -> AG-UI
239
- MCP Stack Agent
240
- -> MCP
241
- MCP Stack Server
242
- -> Gateway / AuthGateway
243
- -> SaaS API
244
- ```
245
-
246
- That means:
247
-
248
- - assistant text and tool progress stream as AG-UI events
249
- - `clientTools` map to AG-UI frontend tools
250
- - server MCP tools execute server-side through Gateway/AuthGateway
251
- - budgets, logs, and permissions still apply to server-side work
252
- - existing `useAppAgent`, `createAppAgent`, and `McpStackChat` integrations do not need a major rewrite
253
-
254
231
  ## OAuth
255
232
 
256
233
  If an external MCP client needs user-scoped OAuth:
@@ -106,7 +106,7 @@ interface McpStackAgentConfig {
106
106
  oauthClientMetadataUrl?: string;
107
107
  /**
108
108
  * Callback to get the auth token for MCP Stack API requests.
109
- * If provided, called before each agent run request.
109
+ * If provided, called before each chat API request.
110
110
  * Use this when your session token may expire and needs refresh (e.g., dashboard playground).
111
111
  * If not provided, uses the static `apiKey` value.
112
112
  */
@@ -429,9 +429,8 @@ type EventHandler<T> = (data: T) => void;
429
429
  * Framework-agnostic — works in any JavaScript environment.
430
430
  *
431
431
  * Handles:
432
- * - Communication with the MCP Stack AG-UI run endpoint (SSE streaming)
433
- * - AG-UI frontend tool execution via configured clientTools
434
- * - MCP server auth/session helpers for legacy and explicit auth flows
432
+ * - Communication with the MCP Stack chat API (SSE streaming)
433
+ * - Tool execution via MCP server (browser-side, with user's auth token)
435
434
  * - Conversation state management
436
435
  * - Event emission for UI updates
437
436
  */
@@ -498,11 +497,6 @@ declare class McpStackAgent {
498
497
  submitFeedback(input: SubmitConversationFeedbackRequest): Promise<ConversationFeedback>;
499
498
  /** Convert client tools to the API schema format. */
500
499
  private clientToolsToSchemas;
501
- private clientToolsToAgUiTools;
502
- private buildAgUiContext;
503
- private buildAgUiForwardedProps;
504
- private buildAgUiUserRunInput;
505
- private buildAgUiToolResultRunInput;
506
500
  private resolveExternalUserId;
507
501
  private buildExternalUserContext;
508
502
  /** Latest runtime budget snapshot for the current SDK identity. */
@@ -602,28 +596,18 @@ declare class McpStackAgent {
602
596
  private resolveToken;
603
597
  /**
604
598
  * The core orchestration loop:
605
- * 1. Send message to the AG-UI run endpoint
606
- * 2. Stream assistant text, server MCP tool progress, and frontend tool requests
607
- * 3. If an AG-UI frontend tool is requested, execute the matching clientTool locally
608
- * 4. Send the frontend tool result back as an AG-UI tool message and continue
599
+ * 1. Send message to chat API
600
+ * 2. Stream response
601
+ * 3. If tool_call execute tool via MCP send result continue
602
+ * 4. If message_end done
609
603
  */
610
604
  private runChatLoop;
611
- private executeClientTool;
612
- private callAgUiApi;
613
- private processAgUiStream;
614
- private recordToolResult;
615
- private recordToolError;
616
- private serializeToolContent;
617
- private parseToolContent;
618
- private parseToolArguments;
619
- private getRecordField;
620
- private getStringField;
621
- private getNumberField;
605
+ private callChatApi;
622
606
  private fetchConversationMessages;
623
607
  private applyConversationPage;
624
608
  private mapReplayMessage;
625
609
  /**
626
- * Process a legacy chat SSE stream.
610
+ * Process an SSE stream from the chat API.
627
611
  * Returns when the stream ends (either message_end or tool_call).
628
612
  */
629
613
  private processSseStream;
@@ -106,7 +106,7 @@ interface McpStackAgentConfig {
106
106
  oauthClientMetadataUrl?: string;
107
107
  /**
108
108
  * Callback to get the auth token for MCP Stack API requests.
109
- * If provided, called before each agent run request.
109
+ * If provided, called before each chat API request.
110
110
  * Use this when your session token may expire and needs refresh (e.g., dashboard playground).
111
111
  * If not provided, uses the static `apiKey` value.
112
112
  */
@@ -429,9 +429,8 @@ type EventHandler<T> = (data: T) => void;
429
429
  * Framework-agnostic — works in any JavaScript environment.
430
430
  *
431
431
  * Handles:
432
- * - Communication with the MCP Stack AG-UI run endpoint (SSE streaming)
433
- * - AG-UI frontend tool execution via configured clientTools
434
- * - MCP server auth/session helpers for legacy and explicit auth flows
432
+ * - Communication with the MCP Stack chat API (SSE streaming)
433
+ * - Tool execution via MCP server (browser-side, with user's auth token)
435
434
  * - Conversation state management
436
435
  * - Event emission for UI updates
437
436
  */
@@ -498,11 +497,6 @@ declare class McpStackAgent {
498
497
  submitFeedback(input: SubmitConversationFeedbackRequest): Promise<ConversationFeedback>;
499
498
  /** Convert client tools to the API schema format. */
500
499
  private clientToolsToSchemas;
501
- private clientToolsToAgUiTools;
502
- private buildAgUiContext;
503
- private buildAgUiForwardedProps;
504
- private buildAgUiUserRunInput;
505
- private buildAgUiToolResultRunInput;
506
500
  private resolveExternalUserId;
507
501
  private buildExternalUserContext;
508
502
  /** Latest runtime budget snapshot for the current SDK identity. */
@@ -602,28 +596,18 @@ declare class McpStackAgent {
602
596
  private resolveToken;
603
597
  /**
604
598
  * The core orchestration loop:
605
- * 1. Send message to the AG-UI run endpoint
606
- * 2. Stream assistant text, server MCP tool progress, and frontend tool requests
607
- * 3. If an AG-UI frontend tool is requested, execute the matching clientTool locally
608
- * 4. Send the frontend tool result back as an AG-UI tool message and continue
599
+ * 1. Send message to chat API
600
+ * 2. Stream response
601
+ * 3. If tool_call execute tool via MCP send result continue
602
+ * 4. If message_end done
609
603
  */
610
604
  private runChatLoop;
611
- private executeClientTool;
612
- private callAgUiApi;
613
- private processAgUiStream;
614
- private recordToolResult;
615
- private recordToolError;
616
- private serializeToolContent;
617
- private parseToolContent;
618
- private parseToolArguments;
619
- private getRecordField;
620
- private getStringField;
621
- private getNumberField;
605
+ private callChatApi;
622
606
  private fetchConversationMessages;
623
607
  private applyConversationPage;
624
608
  private mapReplayMessage;
625
609
  /**
626
- * Process a legacy chat SSE stream.
610
+ * Process an SSE stream from the chat API.
627
611
  * Returns when the stream ends (either message_end or tool_call).
628
612
  */
629
613
  private processSseStream;