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":{}}}'
Click to show internal directories.
Click to hide internal directories.