@@ -16,9 +16,10 @@ import (
1616)
1717
1818type mcpTool struct {
19- mcpName string
20- tool mcp.Tool
21- mcpConfig config.MCPServer
19+ mcpName string
20+ tool mcp.Tool
21+ mcpConfig config.MCPServer
22+ permissions permission.Service
2223}
2324
2425type MCPClient interface {
@@ -80,7 +81,7 @@ func runTool(ctx context.Context, c MCPClient, toolName string, input string) (t
8081
8182func (b * mcpTool ) Run (ctx context.Context , params tools.ToolCall ) (tools.ToolResponse , error ) {
8283 permissionDescription := fmt .Sprintf ("execute %s with the following parameters: %s" , b .Info ().Name , params .Input )
83- p := permission . Default .Request (
84+ p := b . permissions .Request (
8485 permission.CreatePermissionRequest {
8586 Path : config .WorkingDirectory (),
8687 ToolName : b .Info ().Name ,
@@ -118,17 +119,18 @@ func (b *mcpTool) Run(ctx context.Context, params tools.ToolCall) (tools.ToolRes
118119 return tools .NewTextErrorResponse ("invalid mcp type" ), nil
119120}
120121
121- func NewMcpTool (name string , tool mcp.Tool , mcpConfig config.MCPServer ) tools.BaseTool {
122+ func NewMcpTool (name string , tool mcp.Tool , permissions permission. Service , mcpConfig config.MCPServer ) tools.BaseTool {
122123 return & mcpTool {
123- mcpName : name ,
124- tool : tool ,
125- mcpConfig : mcpConfig ,
124+ mcpName : name ,
125+ tool : tool ,
126+ mcpConfig : mcpConfig ,
127+ permissions : permissions ,
126128 }
127129}
128130
129131var mcpTools []tools.BaseTool
130132
131- func getTools (ctx context.Context , name string , m config.MCPServer , c MCPClient ) []tools.BaseTool {
133+ func getTools (ctx context.Context , name string , m config.MCPServer , permissions permission. Service , c MCPClient ) []tools.BaseTool {
132134 var stdioTools []tools.BaseTool
133135 initRequest := mcp.InitializeRequest {}
134136 initRequest .Params .ProtocolVersion = mcp .LATEST_PROTOCOL_VERSION
@@ -149,13 +151,13 @@ func getTools(ctx context.Context, name string, m config.MCPServer, c MCPClient)
149151 return stdioTools
150152 }
151153 for _ , t := range tools .Tools {
152- stdioTools = append (stdioTools , NewMcpTool (name , t , m ))
154+ stdioTools = append (stdioTools , NewMcpTool (name , t , permissions , m ))
153155 }
154156 defer c .Close ()
155157 return stdioTools
156158}
157159
158- func GetMcpTools (ctx context.Context ) []tools.BaseTool {
160+ func GetMcpTools (ctx context.Context , permissions permission. Service ) []tools.BaseTool {
159161 if len (mcpTools ) > 0 {
160162 return mcpTools
161163 }
@@ -172,7 +174,7 @@ func GetMcpTools(ctx context.Context) []tools.BaseTool {
172174 continue
173175 }
174176
175- mcpTools = append (mcpTools , getTools (ctx , name , m , c )... )
177+ mcpTools = append (mcpTools , getTools (ctx , name , m , permissions , c )... )
176178 case config .MCPSse :
177179 c , err := client .NewSSEMCPClient (
178180 m .URL ,
@@ -182,7 +184,7 @@ func GetMcpTools(ctx context.Context) []tools.BaseTool {
182184 log .Printf ("error creating mcp client: %s" , err )
183185 continue
184186 }
185- mcpTools = append (mcpTools , getTools (ctx , name , m , c )... )
187+ mcpTools = append (mcpTools , getTools (ctx , name , m , permissions , c )... )
186188 }
187189 }
188190
0 commit comments