Skip to content

Commit ba17b3e

Browse files
committed
fixup working examples
1 parent cffb3f0 commit ba17b3e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/examples/client/elicitationStreamableHttp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
ElicitRequestURLParams,
1414
McpError,
1515
ErrorCode,
16-
ElicitationRequiredError,
16+
UrlElicitationRequiredError,
1717
ElicitationCompleteNotificationSchema
1818
} from '../../types.js';
1919
import { getDisplayName } from '../../shared/metadataUtils.js';
@@ -742,7 +742,7 @@ async function callTool(name: string, args: Record<string, unknown>): Promise<vo
742742
console.log(`\nFound ${resourceLinks.length} resource link(s). Use 'read-resource <uri>' to read their content.`);
743743
}
744744
} catch (error) {
745-
if (error instanceof ElicitationRequiredError) {
745+
if (error instanceof UrlElicitationRequiredError) {
746746
console.log('\n🔔 Elicitation Required Error Received:');
747747
console.log(`Message: ${error.message}`);
748748
for (const e of error.elicitations) {

src/examples/server/elicitationStreamableHttp.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getOAuthProtectedResourceMetadataUrl, mcpAuthMetadataRouter } from '../
77
import { requireBearerAuth } from '../../server/auth/middleware/bearerAuth.js';
88
import {
99
CallToolResult,
10-
ElicitationRequiredError,
10+
UrlElicitationRequiredError,
1111
ElicitRequestURLParams,
1212
ElicitResult,
1313
isInitializeRequest,
@@ -54,7 +54,7 @@ const getServer = () => {
5454
const elicitationId = generateTrackedElicitation(sessionId, async (notification: ElicitationCompleteNotification) => {
5555
await mcpServer.server.notification(notification);
5656
});
57-
throw new ElicitationRequiredError([
57+
throw new UrlElicitationRequiredError([
5858
{
5959
mode: 'url',
6060
message: 'This tool requires a payment confirmation. Open the link to confirm payment!',
@@ -98,7 +98,7 @@ const getServer = () => {
9898
completeURLElicitation(elicitationId);
9999
}, 5000);
100100

101-
throw new ElicitationRequiredError([
101+
throw new UrlElicitationRequiredError([
102102
{
103103
mode: 'url',
104104
message: 'This tool requires access to your example.com account. Open the link to authenticate!',

src/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,7 @@ export class McpError extends Error {
16641664
if (code === ErrorCode.UrlElicitationRequired && data) {
16651665
const errorData = data as { elicitations?: unknown[] };
16661666
if (errorData.elicitations) {
1667-
return new ElicitationRequiredError(errorData.elicitations as ElicitRequestURLParams[], message);
1667+
return new UrlElicitationRequiredError(errorData.elicitations as ElicitRequestURLParams[], message);
16681668
}
16691669
}
16701670

@@ -1674,11 +1674,11 @@ export class McpError extends Error {
16741674
}
16751675

16761676
/**
1677-
* Specialized error type for elicitation required errors.
1677+
* Specialized error type when a tool requires a URL mode elicitation.
16781678
* This makes it nicer for the client to handle since there is specific data to work with instead of just a code to check against.
16791679
*/
1680-
export class ElicitationRequiredError extends McpError {
1681-
constructor(elicitations: ElicitRequestURLParams[], message: string = `Elicitation${elicitations.length > 1 ? 's' : ''} required`) {
1680+
export class UrlElicitationRequiredError extends McpError {
1681+
constructor(elicitations: ElicitRequestURLParams[], message: string = `URL elicitation${elicitations.length > 1 ? 's' : ''} required`) {
16821682
super(ErrorCode.UrlElicitationRequired, message, {
16831683
elicitations: elicitations
16841684
});

0 commit comments

Comments
 (0)