Skip to content

Commit 38dfe31

Browse files
committed
Rename Callbacks --> Hooks
1 parent 51390c1 commit 38dfe31

File tree

12 files changed

+372
-372
lines changed

12 files changed

+372
-372
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,16 +511,16 @@ For examples, see the `examples/` directory.
511511

512512
## Extras
513513

514-
### Request Callbacks
514+
### Request Hooks
515515

516-
Hook into the request lifecycle by creating a `Callbacks` object with your
516+
Hook into the request lifecycle by creating a `Hooks` object with your
517517
selection among the possible callbacks. This enables telemetry across all
518518
functionality, and observability of various facts, for example the ability
519519
to count improperly-formatted requests, or to log the agent identity during
520520
initialization.
521521

522-
Add the `Callbacks` to the server at the time of creation using the
523-
`server.WithCallbacks` option.
522+
Add the `Hooks` to the server at the time of creation using the
523+
`server.WithHooks` option.
524524

525525
## Contributing
526526

examples/everything/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,27 @@ const (
3030

3131
func NewMCPServer() *server.MCPServer {
3232

33-
callbacks := &server.Callbacks{}
33+
hooks := &server.Hooks{}
3434

35-
callbacks.AddBeforeAny(func(id any, method mcp.MCPMethod, message any) {
35+
hooks.AddBeforeAny(func(id any, method mcp.MCPMethod, message any) {
3636
fmt.Printf("beforeAny: %s, %v, %v\n", method, id, message)
3737
})
38-
callbacks.AddAfterAny(func(id any, method mcp.MCPMethod, message any, result any) {
38+
hooks.AddAfterAny(func(id any, method mcp.MCPMethod, message any, result any) {
3939
fmt.Printf("afterAny: %s, %v, %v, %v\n", method, id, message, result)
4040
})
41-
callbacks.AddOnError(func(id any, method mcp.MCPMethod, message any, err error) {
41+
hooks.AddOnError(func(id any, method mcp.MCPMethod, message any, err error) {
4242
fmt.Printf("onError: %s, %v, %v, %v\n", method, id, message, err)
4343
})
44-
callbacks.AddBeforeInitialize(func(id any, message *mcp.InitializeRequest) {
44+
hooks.AddBeforeInitialize(func(id any, message *mcp.InitializeRequest) {
4545
fmt.Printf("beforeInitialize: %v, %v\n", id, message)
4646
})
47-
callbacks.AddAfterInitialize(func(id any, message *mcp.InitializeRequest, result *mcp.InitializeResult) {
47+
hooks.AddAfterInitialize(func(id any, message *mcp.InitializeRequest, result *mcp.InitializeResult) {
4848
fmt.Printf("afterInitialize: %v, %v, %v\n", id, message, result)
4949
})
50-
callbacks.AddAfterCallTool(func(id any, message *mcp.CallToolRequest, result *mcp.CallToolResult) {
50+
hooks.AddAfterCallTool(func(id any, message *mcp.CallToolRequest, result *mcp.CallToolResult) {
5151
fmt.Printf("afterCallTool: %v, %v, %v\n", id, message, result)
5252
})
53-
callbacks.AddBeforeCallTool(func(id any, message *mcp.CallToolRequest) {
53+
hooks.AddBeforeCallTool(func(id any, message *mcp.CallToolRequest) {
5454
fmt.Printf("beforeCallTool: %v, %v\n", id, message)
5555
})
5656

@@ -60,7 +60,7 @@ func NewMCPServer() *server.MCPServer {
6060
server.WithResourceCapabilities(true, true),
6161
server.WithPromptCapabilities(true),
6262
server.WithLogging(),
63-
server.WithCallbacks(callbacks),
63+
server.WithHooks(hooks),
6464
)
6565

6666
mcpServer.AddResource(mcp.NewResource("test://static/resource",

0 commit comments

Comments
 (0)