MCPcopy Index your code
hub / github.com/github/github-mcp-server / TestWithMCPParse

Function TestWithMCPParse

pkg/http/middleware/mcp_parse_test.go:15–169  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestWithMCPParse(t *testing.T) {
16 tests := []struct {
17 name string
18 method string
19 path string
20 body string
21 expectInfo bool
22 expectedMethod string
23 expectedItem string
24 expectedOwner string
25 expectedRepo string
26 expectedArgs map[string]any
27 }{
28 {
29 name: "health check path is skipped",
30 method: http.MethodPost,
31 path: "/_ping",
32 body: `{"jsonrpc":"2.0","method":"tools/list"}`,
33 expectInfo: false,
34 },
35 {
36 name: "GET request is skipped",
37 method: http.MethodGet,
38 path: "/mcp",
39 body: `{"jsonrpc":"2.0","method":"tools/list"}`,
40 expectInfo: false,
41 },
42 {
43 name: "empty body is skipped",
44 method: http.MethodPost,
45 path: "/mcp",
46 body: "",
47 expectInfo: false,
48 },
49 {
50 name: "invalid JSON is skipped",
51 method: http.MethodPost,
52 path: "/mcp",
53 body: "not valid json",
54 expectInfo: false,
55 },
56 {
57 name: "non-JSON-RPC 2.0 is skipped",
58 method: http.MethodPost,
59 path: "/mcp",
60 body: `{"jsonrpc":"1.0","method":"tools/list"}`,
61 expectInfo: false,
62 },
63 {
64 name: "empty method is skipped",
65 method: http.MethodPost,
66 path: "/mcp",
67 body: `{"jsonrpc":"2.0","method":""}`,
68 expectInfo: false,
69 },
70 {
71 name: "tools/list parses method only",
72 method: http.MethodPost,

Callers

nothing calls this directly

Calls 2

WithMCPParseFunction · 0.85
ServeHTTPMethod · 0.80

Tested by

no test coverage detected