TestServerCapabilitiesOverWire verifies that server capabilities are correctly sent over the wire during initialization.
(t *testing.T)
| 862 | // TestServerCapabilitiesOverWire verifies that server capabilities are |
| 863 | // correctly sent over the wire during initialization. |
| 864 | func TestServerCapabilitiesOverWire(t *testing.T) { |
| 865 | tool := &Tool{Name: "test-tool", InputSchema: &jsonschema.Schema{Type: "object"}} |
| 866 | |
| 867 | testCases := []struct { |
| 868 | name string |
| 869 | serverOpts *ServerOptions |
| 870 | configureServer func(s *Server) |
| 871 | wantCapabilities *ServerCapabilities |
| 872 | }{ |
| 873 | { |
| 874 | name: "Default capabilities", |
| 875 | serverOpts: nil, |
| 876 | configureServer: func(s *Server) {}, |
| 877 | wantCapabilities: &ServerCapabilities{ |
| 878 | Logging: &LoggingCapabilities{}, |
| 879 | }, |
| 880 | }, |
| 881 | { |
| 882 | name: "Custom Capabilities with tools", |
| 883 | serverOpts: &ServerOptions{ |
| 884 | Capabilities: &ServerCapabilities{ |
| 885 | Tools: &ToolCapabilities{ListChanged: false}, |
| 886 | }, |
| 887 | }, |
| 888 | configureServer: func(s *Server) {}, |
| 889 | wantCapabilities: &ServerCapabilities{ |
| 890 | Tools: &ToolCapabilities{ListChanged: false}, |
| 891 | }, |
| 892 | }, |
| 893 | { |
| 894 | name: "Dynamic tool capability", |
| 895 | serverOpts: &ServerOptions{ |
| 896 | Capabilities: &ServerCapabilities{ |
| 897 | Logging: &LoggingCapabilities{}, |
| 898 | }, |
| 899 | }, |
| 900 | configureServer: func(s *Server) { |
| 901 | s.AddTool(tool, nil) |
| 902 | }, |
| 903 | wantCapabilities: &ServerCapabilities{ |
| 904 | Logging: &LoggingCapabilities{}, |
| 905 | Tools: &ToolCapabilities{ListChanged: true}, |
| 906 | }, |
| 907 | }, |
| 908 | { |
| 909 | name: "Extensions over wire", |
| 910 | serverOpts: func() *ServerOptions { |
| 911 | caps := &ServerCapabilities{ |
| 912 | Logging: &LoggingCapabilities{}, |
| 913 | } |
| 914 | caps.AddExtension("io.example/ext", map[string]any{"key": "value"}) |
| 915 | return &ServerOptions{Capabilities: caps} |
| 916 | }(), |
| 917 | configureServer: func(s *Server) {}, |
| 918 | wantCapabilities: &ServerCapabilities{ |
| 919 | Extensions: map[string]any{ |
| 920 | "io.example/ext": map[string]any{"key": "value"}, |
| 921 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…