8000 add filter tool by auth by alonhar · Pull Request #129 · punkpeye/fastmcp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add filter tool by auth #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

add filter tool by auth #129

wants to merge 9 commits into from

Conversation

alonhar
Copy link
@alonhar alonhar commented Jun 23, 2025

What changed

  • Added optional canAccess property to the Tool type definition
  • Fixed HTTP stream server tool filtering to use the new authorization method

Problem

The code was trying to call a non-existent private method tool.#canAccess(auth) when filtering tools for authenticated users, causing TypeScript errors.

Solution

  • Added canAccess?: (auth: T) => boolean to the Tool type
  • Updated filtering logic to properly check if the method exists before calling it
  • Tools without this method default to being accessi 8000 ble to all authenticated users

Usage

server.addTool({
  name: "admin-only-tool",
  canAccess: (auth) => auth?.role === "admin",
  execute: async (args, context) => {
    // Tool implementation
  }
});

@punkpeye
Copy link
Owner

Looks good. Please make sure to add tests and documentation

@alonhar
Copy link
Author
alonhar commented Jun 23, 2025

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0