Skip to content

MCPTool/server parsing error #487

@keiserS

Description

@keiserS

Bug Report

Overview

When in the list of tools, I added the MCP tool with the address: 'https://mcp.deepwiki.com/mcp'

 var tools = new List<Tool>
            {
                Tool.GetOrCreateTool(typeof(DateTimeUtility), nameof(DateTimeUtility.GetDateTime)),
                new MCPTool("deepwiki", "https://mcp.deepwiki.com/mcp")
                //new MCPTool("my_mcp_server", "https://localhost:7295/mcp")  
            };


I got this error on running that AI response (class Program already posted here: Bug report #486

Failed to parse Response -> {
  "id": "resp_68d00339b320819c983bba521592dd0700a1a74376246095",
  "object": "response",
  "created_at": 1758462777,
  "status": "completed",
  "background": false,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "max_tool_calls": null,
  "model": "gpt-4.1-nano-2025-04-14",
  "output": [
    {
      "id": "mcpl_68d00339d8bc819c9a24c51eabf42e5400a1a74376246095",
      "type": "mcp_list_tools",
      "server_label": "deepwiki",
      "tools": [
        {
          "annotations": {
            "read_only": false
          },
          "description": "Get a list of documentation topics for a GitHub repository",
          "input_schema": {
            "type": "object",
            "properties": {
              "repoName": {
                "type": "string",
                "description": "GitHub repository: owner/repo (e.g. \"facebook/react\")"
              }
            },
            "required": [
              "repoName"
            ],
            "additionalProperties": false,
            "$schema": "http://json-schema.org/draft-07/schema#"
          },
          "name": "read_wiki_structure"
        },
        {
          "annotations": {
            "read_only": false
          },
          "description": "View documentation about a GitHub repository",
          "input_schema": {
            "type": "object",
            "properties": {
              "repoName": {
                "type": "string",
                "description": "GitHub repository: owner/repo (e.g. \"facebook/react\")"
              }
            },
            "required": [
              "repoName"
            ],
            "additionalProperties": false,
            "$schema": "http://json-schema.org/draft-07/schema#"
          },
          "name": "read_wiki_contents"
        },
        {
          "annotations": {
            "read_only": false
          },
          "description": "Ask any question about a GitHub repository",
          "input_schema": {
            "type": "object",
            "properties": {
              "repoName": {
                "type": "string",
                "description": "GitHub repository: owner/repo (e.g. \"facebook/react\")"
              },
              "question": {
                "type": "string",
                "description": "The question to ask about the repository"
              }
            },
            "required": [
              "repoName",
              "question"
            ],
            "additionalProperties": false,
            "$schema": "http://json-schema.org/draft-07/schema#"
          },
          "name": "ask_question"
        }
      ]
    },
    {
      "id": "msg_68d0033cc450819cbcffdeb84c6166e100a1a74376246095",
      "type": "message",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "annotations": [],
          "logprobs": [],
          "text": "Hello! How can I help you today?"
        }
      ],
      "role": "assistant"
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "prompt_cache_key": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "safety_identifier": null,
  "service_tier": "default",
  "store": true,
  "temperature": 1.0,
  "text": {
    "format": {
      "type": "text"
    },
    "verbosity": "medium"
  },
  "tool_choice": "auto",
  "tools": [
    {
      "type": "function",
      "description": null,
      "name": "GetDateTime_83c964258964c5b11c046b612a4beb40",
      "parameters": {
        "type": "object",
        "properties": {},
        "additionalProperties": false,
        "required": []
      },
      "strict": true
    },
    {
      "type": "mcp",
      "allowed_tools": null,
      "headers": null,
      "require_approval": "always",
      "server_description": null,
      "server_label": "deepwiki",
      "server_url": "https://mcp.deepwiki.com/<redacted>"
    }
  ],
  "top_logprobs": 0,
  "top_p": 1.0,
  "truncation": "auto",
  "usage": {
    "input_tokens": 219,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 11,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 230
  },
  "user": null,
  "metadata": {}
}
System.Text.Json.JsonException: The JSON value could not be converted to System.String. Path: $.tools[0].input_schema | LineNumber: 0 | BytePositionInLine: 247.
 ---> System.InvalidOperationException: Cannot get the value of a token type 'StartObject' as a string.
   at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedString(JsonTokenType tokenType)
   at System.Text.Json.Utf8JsonReader.GetString()
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](JsonElement element, JsonSerializerOptions options)
   at OpenAI.Responses.ResponseItemConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in F:\Downloads\OpenAI-DotNet-main\OpenAI-DotNet-main\OpenAI-DotNet\Extensions\ResponseItemConverter.cs:line 35
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromNode[TValue](JsonNode node, JsonTypeInfo`1 jsonTypeInfo)
   at OpenAI.Extensions.ResponseExtensions.Deserialize[T](HttpResponseMessage response, JsonNode jNode, OpenAIClient client) in F:\Downloads\OpenAI-DotNet-main\OpenAI-DotNet-main\OpenAI-DotNet\Extensions\ResponseExtensions.cs:line 338
*********************************************************************
>>>>> StreamCallback: error OpenAI.Error
------------------------------------------
>>> Message:The JSON value could not be converted to System.String. Path: $.tools[0].input_schema | LineNumber: 0 | BytePositionInLine: 247. ()

To Reproduce

Use Program.cs from the linked report and change the list of tools.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions