MCPcopy Index your code
hub / github.com/coder/coder / TestMCPHTTP_ToolRegistration

Function TestMCPHTTP_ToolRegistration

coderd/mcp/mcp_test.go:104–133  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func TestMCPHTTP_ToolRegistration(t *testing.T) {
105 t.Parallel()
106
107 logger := testutil.Logger(t)
108
109 server, err := mcpserver.NewServer(logger)
110 require.NoError(t, err)
111
112 // Test registering tools with nil client should return error
113 err = server.RegisterTools(nil)
114 require.Error(t, err)
115 require.Contains(t, err.Error(), "client cannot be nil", "Should reject nil client with appropriate error message")
116
117 // Test registering tools with valid client should succeed
118 client := codersdk.New(testutil.MustURL(t, "http://not-used"))
119 err = server.RegisterTools(client)
120 require.NoError(t, err)
121
122 // Verify that all expected tools are available in the toolsdk
123 expectedToolCount := len(toolsdk.All)
124 require.Greater(t, expectedToolCount, 0, "Should have some tools available")
125
126 // Verify specific tools are present by checking tool names
127 toolNames := make([]string, len(toolsdk.All))
128 for i, tool := range toolsdk.All {
129 toolNames[i] = tool.Name
130 }
131 require.Contains(t, toolNames, toolsdk.ToolNameReportTask, "Should include ReportTask (UserClientOptional)")
132 require.Contains(t, toolNames, toolsdk.ToolNameGetAuthenticatedUser, "Should include GetAuthenticatedUser (requires auth)")
133}

Callers

nothing calls this directly

Calls 6

RegisterToolsMethod · 0.95
LoggerFunction · 0.92
NewFunction · 0.92
MustURLFunction · 0.92
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected