MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / TestToolsCallUnknownTool

Function TestToolsCallUnknownTool

server/mcp/call_test.go:105–138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func TestToolsCallUnknownTool(t *testing.T) {
106 gin.SetMode(gin.TestMode)
107 srv := newTestServer(map[string]*session{
108 "s3": {id: "s3", userID: 1, initialized: true},
109 })
110
111 r := gin.New()
112 r.POST("/mcp", func(c *gin.Context) {
113 common.GinAppendValues(c, conf.UserKey, &model.User{ID: 1, Role: model.ADMIN})
114 srv.handlePost(c)
115 })
116
117 req := httptest.NewRequest(http.MethodPost, "http://example.com/mcp", strings.NewReader(`{
118 "jsonrpc":"2.0",
119 "id":3,
120 "method":"tools/call",
121 "params":{"name":"openlist.fs.unknown","arguments":{"path":"/"}}
122 }`))
123 req.Header.Set("Accept", "application/json, text/event-stream")
124 req.Header.Set("Origin", "http://example.com")
125 req.Header.Set(ProtocolVersionHeader, ProtocolVersion)
126 req.Header.Set(SessionHeader, "s3")
127
128 w := httptest.NewRecorder()
129 r.ServeHTTP(w, req)
130
131 if w.Code != http.StatusOK {
132 t.Fatalf("unexpected status: got %d want %d", w.Code, http.StatusOK)
133 }
134 resp := decodeResponse(t, w)
135 if resp.Error == nil || resp.Error.Code != -32601 {
136 t.Fatalf("unexpected error response: %+v", resp.Error)
137 }
138}
139
140func TestToolsCallInvalidParams(t *testing.T) {
141 gin.SetMode(gin.TestMode)

Callers

nothing calls this directly

Calls 6

GinAppendValuesFunction · 0.92
newTestServerFunction · 0.85
decodeResponseFunction · 0.85
handlePostMethod · 0.80
ServeHTTPMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected