@@ -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 ) {
8283permissionDescription := fmt .Sprintf ("execute %s with the following parameters: %s" , b .Info ().Name , params .Input )
83- p := permission . Default .Request (
84+ p := b . permissions .Request (
8485permission.CreatePermissionRequest {
8586Path : config .WorkingDirectory (),
8687ToolName : b .Info ().Name ,
@@ -118,17 +119,18 @@ func (b *mcpTool) Run(ctx context.Context, params tools.ToolCall) (tools.ToolRes
118119return 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 {
122123return & 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 {
132134var stdioTools []tools.BaseTool
133135initRequest := mcp.InitializeRequest {}
134136initRequest .Params .ProtocolVersion = mcp .LATEST_PROTOCOL_VERSION
@@ -149,13 +151,13 @@ func getTools(ctx context.Context, name string, m config.MCPServer, c MCPClient)
149151return stdioTools
150152}
151153for _ , t := range tools .Tools {
152- stdioTools = append (stdioTools , NewMcpTool (name , t , m ))
154+ stdioTools = append (stdioTools , NewMcpTool (name , t , permissions , m ))
153155}
154156defer c .Close ()
155157return stdioTools
156158}
157159
158- func GetMcpTools (ctx context.Context ) []tools.BaseTool {
160+ func GetMcpTools (ctx context.Context , permissions permission. Service ) []tools.BaseTool {
159161if len (mcpTools ) > 0 {
160162return mcpTools
161163}
@@ -172,7 +174,7 @@ func GetMcpTools(ctx context.Context) []tools.BaseTool {
172174continue
173175}
174176
175- mcpTools = append (mcpTools , getTools (ctx , name , m , c )... )
177+ mcpTools = append (mcpTools , getTools (ctx , name , m , permissions , c )... )
176178case config .MCPSse :
177179c , err := client .NewSSEMCPClient (
178180m .URL ,
@@ -182,7 +184,7 @@ func GetMcpTools(ctx context.Context) []tools.BaseTool {
182184log .Printf ("error creating mcp client: %s" , err )
183185continue
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