per-user-tools

command
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package main demonstrates per-user tool access using ToolProvider.

This example shows how to expose different tools to different users based on their authentication token. This is useful for multi-tenant or role-based access control scenarios.

Test with:

# Alice's tools (has admin access)
curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer alice-secret-token" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

# Bob's tools (regular user)
curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer bob-secret-token" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

# Call Alice's admin tool
curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer alice-secret-token" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"admin_users","arguments":{}}}'

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL