You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set it to `true` to automatically approve all MCP tool calls without user confirmation. This also sets `vim.g.mcphub_auto_approve` variable to `true`. You can toggle this option in the MCP Hub UI with `ga` keymap. You can see the current auto approval status in the Hub UI.
144
+
#### Boolean Auto-Approval
145
+
146
+
Set it to `true` to automatically approve all MCP tool calls without user confirmation:
147
+
148
+
```lua
149
+
require("mcphub").setup({
150
+
auto_approve=true, -- Auto approve all MCP tool calls
151
+
})
152
+
```
153
+
154
+
This also sets `vim.g.mcphub_auto_approve` variable to `true`. You can toggle this option in the MCP Hub UI with `ga` keymap. You can see the current auto approval status in the Hub UI.
**Fine-Grained Auto-Approval**: For more granular control, configure auto-approval per server or per tool using the `autoApprove` field in your `servers.json`. You can also toggle auto-approval from the Hub UI using the `a` keymap on individual servers or tools. See [servers.json configuration](/mcp/servers_json#auto-approval-configuration) for detailed examples and configuration options.
158
+
#### Function-Based Auto-Approval
159
+
160
+
For maximum control, provide a function that decides approval based on the specific tool call:
161
+
162
+
```lua
163
+
require("mcphub").setup({
164
+
auto_approve=function(params)
165
+
-- Auto-approve GitHub issue reading
166
+
ifparams.server_name=="github" andparams.tool_name=="get_issue" then
167
+
returntrue-- Auto approve
168
+
end
169
+
170
+
-- Block access to private repos
171
+
ifparams.arguments.repo=="private" then
172
+
return"You can't access my private repo" -- Error message
173
+
end
174
+
175
+
-- Auto-approve safe file operations in current project
176
+
ifparams.tool_name=="read_file" then
177
+
localpath=params.arguments.pathor""
178
+
ifpath:match("^" ..vim.fn.getcwd()) then
179
+
returntrue-- Auto approve
180
+
end
181
+
end
182
+
183
+
-- Check if tool is configured for auto-approval in servers.json
184
+
ifparams.is_auto_approved_in_serverthen
185
+
returntrue-- Respect servers.json configuration
186
+
end
187
+
188
+
returnfalse-- Show confirmation prompt
189
+
end,
190
+
})
191
+
```
192
+
193
+
**Parameters available in the function:**
194
+
-`params.server_name` - Name of the MCP server
195
+
-`params.tool_name` - Name of the tool being called (nil for resources)
196
+
-`params.arguments` - Table of arguments passed to the tool
197
+
-`params.action` - Either "use_mcp_tool" or "access_mcp_resource"
198
+
-`params.uri` - Resource URI (for resource access)
199
+
-`params.is_auto_approved_in_server` - Boolean indicating if tool is configured for auto-approval in servers.json
200
+
201
+
**Return values:**
202
+
-`true` - Auto-approve the call
203
+
-`false` - Show confirmation prompt
204
+
-`string` - Deny with error message
205
+
-`nil` - Show confirmation prompt (same as false)
206
+
207
+
#### Server-Level Auto-Approval
208
+
209
+
For fine-grained control per server or tool, configure auto-approval using the `autoApprove` field in your `servers.json`. You can also toggle auto-approval from the Hub UI using the `a` keymap on individual servers or tools. See [servers.json configuration](/mcp/servers_json#auto-approval-configuration) for detailed examples and configuration options.
210
+
211
+
#### Auto-Approval Priority
212
+
213
+
The system checks auto-approval in this order:
214
+
1.**Function**: Custom `auto_approve` function (if provided)
215
+
2.**Server-specific**: `autoApprove` field in server config
0 commit comments