Skip to content

Commit 6453c5f

Browse files
fjakobsclaude
andauthored
MCP: Bring Databricks provider to the state of the Rust Version (#3941)
## Summary * Rewrite Databircks provider by directly porting https://github.com/neondatabase/appdotbuild-agent/blob/main/edda/edda_integrations/src/databricks.rs from the latest main branch * Add pagination * Add filtering * Add table search * Simplify the code --------- Co-authored-by: Claude <[email protected]>
1 parent a9984ef commit 6453c5f

File tree

18 files changed

+2174
-666
lines changed

18 files changed

+2174
-666
lines changed

experimental/apps-mcp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Understand your Databricks data before building:
8181

8282
- **`databricks_list_catalogs`** - Discover available data catalogs
8383
- **`databricks_list_schemas`** - Browse schemas in a catalog
84-
- **`databricks_list_tables`** - Find tables in a schema
84+
- **`databricks_find_tables`** - Find tables in a schema
8585
- **`databricks_describe_table`** - Get table details, columns, and sample data
8686
- **`databricks_execute_query`** - Test queries and preview data
8787

experimental/apps-mcp/cmd/apps_mcp.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package mcp
22

33
import (
4+
"errors"
5+
"os"
6+
47
"github.com/databricks/cli/cmd/root"
58
mcplib "github.com/databricks/cli/experimental/apps-mcp/lib"
69
"github.com/databricks/cli/experimental/apps-mcp/lib/server"
@@ -38,6 +41,13 @@ The server communicates via stdio using the Model Context Protocol.`,
3841
RunE: func(cmd *cobra.Command, args []string) error {
3942
ctx := cmd.Context()
4043

44+
if warehouseID == "" {
45+
warehouseID = os.Getenv("DATABRICKS_WAREHOUSE_ID")
46+
if warehouseID == "" {
47+
return errors.New("DATABRICKS_WAREHOUSE_ID environment variable is required")
48+
}
49+
}
50+
4151
w := cmdctx.WorkspaceClient(ctx)
4252

4353
// Build MCP config from flags

experimental/apps-mcp/lib/mcp/server.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ func (s *Server) AddTool(tool *Tool, handler ToolHandler) {
4343
}
4444
}
4545

46+
// GetTools returns all registered tools.
47+
func (s *Server) GetTools() []*Tool {
48+
s.toolsMu.RLock()
49+
defer s.toolsMu.RUnlock()
50+
51+
tools := make([]*Tool, 0, len(s.tools))
52+
for _, st := range s.tools {
53+
tools = append(tools, st.tool)
54+
}
55+
return tools
56+
}
57+
4658
// Run starts the MCP server with the given transport.
4759
func (s *Server) Run(ctx context.Context, transport *StdioTransport) error {
4860
s.transport = transport

experimental/apps-mcp/lib/mcp/types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package mcp
33

44
import (
55
"context"
6+
"fmt"
67
)
78

89
// Implementation represents server or client implementation details.
@@ -41,3 +42,16 @@ type ToolHandler func(context.Context, *CallToolRequest) (*CallToolResult, error
4142

4243
// ToolHandlerFor is a typed handler for tool calls with automatic marshaling.
4344
type ToolHandlerFor[In, Out any] func(context.Context, *CallToolRequest, In) (*CallToolResult, Out, error)
45+
46+
func CreateNewTextContentResult(text string) *CallToolResult {
47+
return &CallToolResult{
48+
Content: []Content{&TextContent{Type: "text", Text: text}},
49+
}
50+
}
51+
52+
func CreateNewTextContentResultError(err error) *CallToolResult {
53+
return &CallToolResult{
54+
Content: []Content{&TextContent{Type: "text", Text: fmt.Sprintf("Error: %v", err)}},
55+
IsError: true,
56+
}
57+
}

experimental/apps-mcp/lib/providers/databricks/catalogs.go

Lines changed: 0 additions & 162 deletions
This file was deleted.

0 commit comments

Comments
 (0)