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
{{ message }}
Repository navigation
Enable FastMCP to filter tools, prompts, resources using a fine grained policy #1031
The authorization protocol allows MCP to implement course grained authorization checks e.g. a principal can/cannot access the server.
For advanced use cases though it is useful to be able to limit access on a per tool/resource/prompt basis.
There are a range of authorization tools that can be used however rather than being specific I suggest it is better to provide a plugin API that allows providers to pick their underlying authorization approach.
I have a patch that shows this idea, I'll open a draft pull request to illustrate the idea and allow for further testing & refinement.
Just wanted to add a +1 in the need of this feature.
Some more context in case it helps: Adding this would bring parity with the TS SDK that already is possible to use fine grained policies. At Auth0 we implemented a sample app in TS that has this capability and can be found here and we were looking to do the same in Python which is not possible in the tests we've done so far.
@davemssavage this fine-grained policy idea is very close to the layer I am working on.
I am building Agent_Sudo as a policy/audit gateway for MCP tool execution. The policy decision takes actor, tool, prompt/resource, arguments, target resource/path, TTL, and max-use constraints, then returns allow, deny, approval-needed, or delegated-allow. Each decision is logged.
For FastMCP, would you expect this policy layer to live inside the server framework itself, or would a middleware/gateway around an MCP server be acceptable?
There is a useful scope split here now that #3613 has landed: the SDK has a documented mechanism that can refuse a tools/call before the handler runs, so the remaining question in this issue is less "can Python enforce a policy?" and more "what policy surface should FastMCP standardize?"
I think it would help to separate two capabilities that are easy to conflate:
visibility/discovery policy — whether a tool/resource/prompt appears in */list for this principal;
execution authorization — whether a concrete invocation with concrete arguments is allowed to reach the handler.
Those are not interchangeable. Hiding a tool from tools/list does not by itself authorize or deny a direct tools/call, and an execution gate may need argument/resource context that discovery-time filtering does not have.
A minimal plugin contract could therefore stay policy-engine agnostic while exposing two explicit hooks (names illustrative):
One implementation could use Auth0/FGA, another ACLs, another local deterministic policy; the SDK would only define where the decision is consumed.
One detail I would want nailed down before an API shape: should the execution hook receive raw request params or the SDK's validated/normalized params? For argument-sensitive authorization, that becomes a security boundary rather than just an ergonomics choice.
If the intended scope of #1031 is discovery filtering only, I'd keep execution authorization explicitly out of it rather than let a single "policy" hook accidentally imply both.
Activity
vndee commentedon Jun 26, 2025
same here, we need this feature!
jtemporal commentedon Dec 12, 2025
Just wanted to add a +1 in the need of this feature.
Some more context in case it helps: Adding this would bring parity with the TS SDK that already is possible to use fine grained policies. At Auth0 we implemented a sample app in TS that has this capability and can be found here and we were looking to do the same in Python which is not possible in the tests we've done so far.
Ram9199 commentedon May 27, 2026
@davemssavage this fine-grained policy idea is very close to the layer I am working on.
I am building Agent_Sudo as a policy/audit gateway for MCP tool execution. The policy decision takes actor, tool, prompt/resource, arguments, target resource/path, TTL, and max-use constraints, then returns allow, deny, approval-needed, or delegated-allow. Each decision is logged.
For FastMCP, would you expect this policy layer to live inside the server framework itself, or would a middleware/gateway around an MCP server be acceptable?
hippoley commentedon Oct 3, 2026
There is a useful scope split here now that #3613 has landed: the SDK has a documented mechanism that can refuse a
tools/callbefore the handler runs, so the remaining question in this issue is less "can Python enforce a policy?" and more "what policy surface should FastMCP standardize?"I think it would help to separate two capabilities that are easy to conflate:
*/listfor this principal;Those are not interchangeable. Hiding a tool from
tools/listdoes not by itself authorize or deny a directtools/call, and an execution gate may need argument/resource context that discovery-time filtering does not have.A minimal plugin contract could therefore stay policy-engine agnostic while exposing two explicit hooks (names illustrative):
One implementation could use Auth0/FGA, another ACLs, another local deterministic policy; the SDK would only define where the decision is consumed.
One detail I would want nailed down before an API shape: should the execution hook receive raw request params or the SDK's validated/normalized params? For argument-sensitive authorization, that becomes a security boundary rather than just an ergonomics choice.
If the intended scope of #1031 is discovery filtering only, I'd keep execution authorization explicitly out of it rather than let a single "policy" hook accidentally imply both.