I just connected my custom MCP server with OAuth authentication (which is a whole other story described in the other threads). It has only search and fetch tools, with a response format conforming to OpenAI requirements, as far as I can tell.
BUT whenever ChatGPT tries to list available tools with api_tool.list_resources, it always ends up in a validation error:
ValidationError: 1 validation error for ObjectSchema
type
Input should be 'object' [type=literal_error, input_value='string', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/literal_error
Did anyone else face such an error? Was anyone able to successfully connect and use their custom MCP?
MCP server has only search and fetch tools.
Tools are listed just fine in OpenAI API prompt editor.
Source code
Search
Summary
import { z } from 'zod';
import { zodToJsonSchema } from 'zod-to-json-schema';
const Params = z.string().describe('Query string for search');
export const searchTool = {
name: 'search',
description: 'Search stub returning hardcoded results matching MCP schema.',
inputSchema: zodToJsonSchema(Params),
async call(args: unknown) {
if (typeof args !== 'string') {
throw new Error('Expected a string argument for search query');
}
const query = args.trim();
if (!query) {
return { results: [] };
}
return {
results: [
{ id: 'doc-1', title: 'Cats: A Brief Overview', url: 'https://example.com/doc-1' },
{ id: 'doc-2', title: 'History of Domestic Cats', url: 'https://example.com/doc-2' },
],
};
},
};
Fetch
Summary
import { z } from 'zod';
import { zodToJsonSchema } from 'zod-to-json-schema';
const Params = z.string().describe('Document id to fetch');
export const fetchTool = {
name: 'fetch',
description: 'Fetch stub returning a hardcoded document matching MCP schema.',
inputSchema: zodToJsonSchema(Params),
async call(args: unknown) {
if (typeof args !== 'string') {
throw new Error('Expected a string argument for document id');
}
const id = args.trim();
if (!id) {
throw new Error('Document id must be a non-empty string');
}
return {
id,
title: 'Stub Document',
text: 'This is a hardcoded document body used to verify that ChatGPT can call the fetch tool and read text content from the MCP server.',
url: `https://example.com/${encodeURIComponent(id)}`,
metadata: { source: 'stub', environment: 'test' },
};
},
};
