Skip to content

Shutting Down MCP Server #23

Open
Open
@nimit2801

Description

@nimit2801
Image
{
  "mcpServers": {
    "google-calendar": {
      "command": "node",
      "args": [
        "/Users/nimitsavant/Desktop/nimit-devrev/google-calendar-mcp/build/index.js"
      ]
    }
  }
}

Activity

mimi3421

mimi3421 commented on Apr 14, 2025

@mimi3421
Contributor

I think there is a Bug somewhere in the request POST JSON message accounting to the null string.

I tested the mcphost locally with the local llama.cpp server with empty mcpServer setting and sent a simple prumpt "hi". The log in mcphost was:

mcphost --model openai:phi4 --openai-url http://localhost:8080/v1 --openai-api-key 000000--debug
2025/04/15 00:29:32 INFO <cmd/root.go:487> Model loaded provider=openai model=phi4

You: hi
2025/04/15 00:29:34 DEBU <openai/provider.go:46> creating message prompt=hi num_messages=1 num_tools=0
2025/04/15 00:29:34 DEBU <openai/provider.go:55> converting message role=user content=hi is_tool_response=false
2025/04/15 00:29:34 DEBU <openai/provider.go:143> sending messages to OpenAI messages="[{Role:user Content:0xc000247560 ReasoningContent: FunctionCall: ToolCalls:[] Name: ToolCallID:}]" num_tools=0
2025/04/15 00:29:34 INFO <cmd/root.go:502> Shutting down MCP servers...
Error: error response with status 500

While the log in llama.cpp was:

srv log_server_r: request: POST /v1/chat/completions 127.0.0.1 500
srv log_server_r: request: {"model":"phi4","messages":[{"role":"user","content":"hi","reasoning_content":null},{"role":"user","content":"hi","reasoning_content":null}],"max_tokens":4096,"temperature":0.7}
srv log_server_r: response: {"error":{"code":500,"message":"Failed to parse messages: [json.exception.type_error.302] type must be string, but is null; messages = [\n {\n "role": "user",\n "content": "hi",\n "reasoning_content": null\n },\n {\n "role": "user",\n "content": "hi",\n "reasoning_content": null\n }\n]","type":"server_error"}}

I think the null in the request JSON should be "" which triggered the error in the JSON parser.

Edited:
I'm new to this and I think maybe the empty reasoning_content field should be omitted in the request POST and not just be set to null.

//pkg/llm/openai/types.go
type MessageParam struct {
	Role             string        `json:"role"`
	Content          *string       `json:"content"`
	ReasoningContent *string       `json:"reasoning_content",omitempty` // Add omitempty here
	FunctionCall     *FunctionCall `json:"function_call,omitempty"`
	ToolCalls        []ToolCall    `json:"tool_calls,omitempty"`
	Name             string        `json:"name,omitempty"`
	ToolCallID       string        `json:"tool_call_id,omitempty"`
}

Similar issues may be shown in link or link

Waasi

Waasi commented on Apr 14, 2025

@Waasi

Pitching in just in case this is still an issue. For me, it turned out that the model I was using was not found. I got to this by logging the error returned here. I hope this helps.

semidark

semidark commented on Apr 19, 2025

@semidark

Pitching in just in case this is still an issue. For me, it turned out that the model I was using was not found. I discovered this by logging the error returned here. I hope this helps.

I ran into the same issue, and at least in my case, @Waasi was correct. For me, not only was the model not found, but I also could not connect to the Ollama server. I had to correctly set my OLLAMA_HOST environment variable. After that, I got my first MCP server up and running.

So, I believe better logging when this error occurs would be really helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Waasi@semidark@mimi3421@nimit2801

        Issue actions

          Shutting Down MCP Server · Issue #23 · mark3labs/mcphost