Server MCP capabilities. Example: >>> caps = ServerCapabilities( ... tools=True, ... prompts=True, ... resources=False, ... experimental={"events": True} ... ) >>> caps.to_display_string() 'Tools, Prompts, Even
| 92 | |
| 93 | |
| 94 | class ServerCapabilities(CommandBaseModel): |
| 95 | """ |
| 96 | Server MCP capabilities. |
| 97 | |
| 98 | Example: |
| 99 | >>> caps = ServerCapabilities( |
| 100 | ... tools=True, |
| 101 | ... prompts=True, |
| 102 | ... resources=False, |
| 103 | ... experimental={"events": True} |
| 104 | ... ) |
| 105 | >>> caps.to_display_string() |
| 106 | 'Tools, Prompts, Events*' |
| 107 | """ |
| 108 | |
| 109 | tools: bool = Field(default=False, description="Supports tools") |
| 110 | prompts: bool = Field(default=False, description="Supports prompts") |
| 111 | resources: bool = Field(default=False, description="Supports resources") |
| 112 | experimental: dict[str, Any] = Field( |
| 113 | default_factory=dict, description="Experimental capabilities" |
| 114 | ) |
| 115 | |
| 116 | @property |
| 117 | def has_events(self) -> bool: |
| 118 | """Check if server has experimental events capability.""" |
| 119 | return cast(bool, self.experimental.get("events", False)) |
| 120 | |
| 121 | @property |
| 122 | def has_streaming(self) -> bool: |
| 123 | """Check if server has experimental streaming capability.""" |
| 124 | return cast(bool, self.experimental.get("streaming", False)) |
| 125 | |
| 126 | def to_display_string(self) -> str: |
| 127 | """Format capabilities as readable string.""" |
| 128 | caps = [] |
| 129 | |
| 130 | if self.tools: |
| 131 | caps.append("Tools") |
| 132 | if self.prompts: |
| 133 | caps.append("Prompts") |
| 134 | if self.resources: |
| 135 | caps.append("Resources") |
| 136 | |
| 137 | if self.has_events: |
| 138 | caps.append("Events*") |
| 139 | if self.has_streaming: |
| 140 | caps.append("Streaming*") |
| 141 | |
| 142 | return ", ".join(caps) if caps else "None" |
no outgoing calls