SPEC COMPLIANCE: Remove loose/passthrough types not allowed/defined by MCP spec + Task types (#1242)
This commit is contained in:
parent
4d6c3b8284
commit
a606fb1790
2 changed files with 866 additions and 488 deletions
|
|
@ -28,11 +28,8 @@ import {
|
|||
ListToolsResultSchema,
|
||||
type LoggingLevel,
|
||||
McpError,
|
||||
type Notification,
|
||||
type ReadResourceRequest,
|
||||
ReadResourceResultSchema,
|
||||
type Request,
|
||||
type Result,
|
||||
type ServerCapabilities,
|
||||
SUPPORTED_PROTOCOL_VERSIONS,
|
||||
type SubscribeRequest,
|
||||
|
|
@ -48,7 +45,10 @@ import {
|
|||
ResourceListChangedNotificationSchema,
|
||||
ListChangedOptions,
|
||||
ListChangedOptionsBaseSchema,
|
||||
type ListChangedHandlers
|
||||
type ListChangedHandlers,
|
||||
type Request,
|
||||
type Notification,
|
||||
type Result
|
||||
} from '../types.js';
|
||||
import { AjvJsonSchemaValidator } from '../validation/ajv-provider.js';
|
||||
import type { JsonSchemaType, JsonSchemaValidator, jsonSchemaValidator } from '../validation/types.js';
|
||||
|
|
@ -368,14 +368,14 @@ export class Client<
|
|||
}
|
||||
|
||||
const { params } = validatedRequest.data;
|
||||
const mode = params.mode ?? 'form';
|
||||
params.mode = params.mode ?? 'form';
|
||||
const { supportsFormMode, supportsUrlMode } = getSupportedElicitationModes(this._capabilities.elicitation);
|
||||
|
||||
if (mode === 'form' && !supportsFormMode) {
|
||||
if (params.mode === 'form' && !supportsFormMode) {
|
||||
throw new McpError(ErrorCode.InvalidParams, 'Client does not support form-mode elicitation requests');
|
||||
}
|
||||
|
||||
if (mode === 'url' && !supportsUrlMode) {
|
||||
if (params.mode === 'url' && !supportsUrlMode) {
|
||||
throw new McpError(ErrorCode.InvalidParams, 'Client does not support URL-mode elicitation requests');
|
||||
}
|
||||
|
||||
|
|
@ -404,9 +404,9 @@ export class Client<
|
|||
}
|
||||
|
||||
const validatedResult = validationResult.data;
|
||||
const requestedSchema = mode === 'form' ? (params.requestedSchema as JsonSchemaType) : undefined;
|
||||
const requestedSchema = params.mode === 'form' ? (params.requestedSchema as JsonSchemaType) : undefined;
|
||||
|
||||
if (mode === 'form' && validatedResult.action === 'accept' && validatedResult.content && requestedSchema) {
|
||||
if (params.mode === 'form' && validatedResult.action === 'accept' && validatedResult.content && requestedSchema) {
|
||||
if (this._capabilities.elicitation?.form?.applyDefaults) {
|
||||
try {
|
||||
applyElicitationDefaults(requestedSchema, validatedResult.content);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Transport, FetchLike, createFetchWithInit, normalizeHeaders } from '../shared/transport.js';
|
||||
import { isInitializedNotification, isJSONRPCRequest, isJSONRPCResponse, JSONRPCMessage, JSONRPCMessageSchema } from '../types.js';
|
||||
import { isInitializedNotification, isJSONRPCRequest, isJSONRPCResultResponse, JSONRPCMessage, JSONRPCMessageSchema } from '../types.js';
|
||||
import { auth, AuthResult, extractWWWAuthenticateParams, OAuthClientProvider, UnauthorizedError } from './auth.js';
|
||||
import { EventSourceParserStream } from 'eventsource-parser/stream';
|
||||
|
||||
|
|
@ -350,7 +350,7 @@ export class StreamableHTTPClientTransport implements Transport {
|
|||
if (!event.event || event.event === 'message') {
|
||||
try {
|
||||
const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));
|
||||
if (isJSONRPCResponse(message)) {
|
||||
if (isJSONRPCResultResponse(message)) {
|
||||
// Mark that we received a response - no need to reconnect for this request
|
||||
receivedResponse = true;
|
||||
if (replayMessageId !== undefined) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue