Skip to main content
Glama
jmandel

Smart EHR MCP Server

by jmandel
p2.17 kB
diff --git a/src/A2AClientV2.ts b/src/A2AClientV2.ts index ead3f1e..a7c9b2d 100644 --- a/src/A2AClientV2.ts +++ b/src/A2AClientV2.ts @@ -360,26 +360,50 @@ private async _startPolling(initialParams: TaskSendParams | null) { this.state = 'starting-poll'; this.abort = new AbortController(); - // initial SEND or GET - let first: Task; - if (initialParams) { - first = await this.transport.request<Task>( - 'tasks/send', - initialParams as TaskSendParams, - this.abort.signal - ); - } else { - first = await this.transport.request<Task>( - 'tasks/get', - { id: this.taskId } as TaskGetParams, - this.abort.signal - ); - } - this.store.apply(first); - if (['completed','canceled','failed'].includes(first.status.state)) { - this._stopComms(true, this._closeReasonFromState(first.status.state)); - return; - } - if (first.status.state === 'input-required') { - this.state = 'input-required'; - return; - } + // initial SEND or GET (with immediate follow-up GET on CREATE) + let first: Task; + if (initialParams) { + // 1) send + const sent = await this.transport.request<Task>( + 'tasks/send', + initialParams as TaskSendParams, + this.abort.signal + ); + this.store.apply(sent); + + // 2) immediate follow-up GET for definitive state + first = await this.transport.request<Task>( + 'tasks/get', + { id: this.taskId } as TaskGetParams, + this.abort.signal + ); + this.store.apply(first); + } else { + // resume path or pure GET + first = await this.transport.request<Task>( + 'tasks/get', + { id: this.taskId } as TaskGetParams, + this.abort.signal + ); + this.store.apply(first); + } + + // handle final or input-required + if (['completed','canceled','failed'].includes(first.status.state)) { + this._stopComms(true, this._closeReasonFromState(first.status.state)); + return; + } + if (first.status.state === 'input-required') { + this.state = 'input-required'; + return; + }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jmandel/health-record-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server