MCPcopy
hub / github.com/googleapis/mcp-toolbox / TestPrebuiltAndCustomTools

Function TestPrebuiltAndCustomTools

cmd/root_test.go:730–932  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

728}
729
730func TestPrebuiltAndCustomTools(t *testing.T) {
731 t.Setenv("SQLITE_DATABASE", "\":memory:\"")
732 // Setup custom config
733 customContent := `
734kind: tool
735name: custom_tool
736type: http
737source: my-http
738method: GET
739path: /
740description: "A custom tool for testing"
741---
742kind: source
743name: my-http
744type: http
745baseUrl: http://example.com
746`
747 customFile := filepath.Join(t.TempDir(), "custom.yaml")
748 if err := os.WriteFile(customFile, []byte(customContent), 0644); err != nil {
749 t.Fatal(err)
750 }
751
752 // Tool Conflict File
753 // SQLite prebuilt has a tool named 'list_tables'
754 toolConflictContent := `
755kind: tool
756name: list_tables
757type: http
758source: my-http
759method: GET
760path: /
761description: "Conflicting tool"
762---
763kind: source
764name: my-http
765type: http
766baseUrl: http://example.com
767`
768 toolConflictFile := filepath.Join(t.TempDir(), "tool_conflict.yaml")
769 if err := os.WriteFile(toolConflictFile, []byte(toolConflictContent), 0644); err != nil {
770 t.Fatal(err)
771 }
772
773 // Source Conflict File
774 // SQLite prebuilt has a source named 'sqlite-source'
775 sourceConflictContent := `
776kind: source
777name: sqlite-source
778type: http
779baseUrl: http://example.com
780---
781kind: tool
782name: dummy_tool
783type: http
784source: sqlite-source
785method: GET
786path: /
787description: "Dummy"

Callers

nothing calls this directly

Calls 2

invokeCommandWithContextFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected