### Valid Product Data Example Source: https://pub.dev/documentation/dart_mcp/latest/server/ObjectSchema-extension-type.html An example of a JSON-like map that conforms to the `productSchema`. ```json { "productId": "ABC12345", "productName": "Super Widget", "price": 19.99, "tags": ["electronics", "gadget"], "dimensions": {"length": 10, "width": 5, "height": 2.5} } ``` -------------------------------- ### MCPServer.fromStreamChannel Implementation Example Source: https://pub.dev/documentation/dart_mcp/latest/server/MCPServer/MCPServer.fromStreamChannel.html Provides an example implementation of the MCPServer.fromStreamChannel constructor, including registration of request and notification handlers. ```dart MCPServer.fromStreamChannel( super.channel, { required this.implementation, this.instructions, super.protocolLogSink, }) { registerRequestHandler(InitializeRequest.methodName, initialize); registerNotificationHandler( InitializedNotification.methodName, handleInitialized, ); } ``` -------------------------------- ### AudioContent Constructor Source: https://pub.dev/documentation/dart_mcp/latest/server/AudioContent/AudioContent.html This section describes the AudioContent constructor, its parameters, and provides an example of its implementation. ```APIDOC ## AudioContent Constructor ### Description This is a factory constructor for creating an `AudioContent` object. ### Parameters - **data** (String) - Required - The audio data. - **mimeType** (String) - Required - The MIME type of the audio data. - **annotations** (Annotations?) - Optional - Annotations for the audio content. - **meta** (Meta?) - Optional - Metadata for the audio content. ### Implementation ```dart factory AudioContent({ required String data, required String mimeType, Annotations? annotations, Meta? meta, }) => AudioContent.fromMap({ Keys.data: data, Keys.mimeType: mimeType, Keys.type: expectedType, if (annotations != null) Keys.annotations: annotations, if (meta != null) Keys.meta: meta, }); ``` ``` -------------------------------- ### ServerConnection.fromStreamChannel Implementation Example Source: https://pub.dev/documentation/dart_mcp/latest/client/ServerConnection/ServerConnection.fromStreamChannel.html Provides a detailed implementation of the ServerConnection.fromStreamChannel constructor, including request and notification handler registrations. ```dart ServerConnection.fromStreamChannel( super.channel, { super.protocolLogSink, RootsSupport? rootsSupport, SamplingSupport? samplingSupport, @Deprecated('Use elicitationFormSupport instead') ElicitationSupport? elicitationSupport, ElicitationFormSupport? elicitationFormSupport, ElicitationUrlSupport? elicitationUrlSupport, }) : _elicitationUrlSupport = elicitationUrlSupport { elicitationFormSupport ??= elicitationSupport; if (rootsSupport != null) { registerRequestHandler( ListRootsRequest.methodName, rootsSupport.handleListRoots, ); } if (samplingSupport != null) { registerRequestHandler( CreateMessageRequest.methodName, (CreateMessageRequest request) => samplingSupport.handleCreateMessage(request, serverInfo!), ); } if (elicitationFormSupport != null || elicitationUrlSupport != null) { registerRequestHandler(ElicitRequest.methodName, (ElicitRequest request) { switch (request.mode) { case ElicitationMode.form: if (elicitationFormSupport != null) { return elicitationFormSupport.handleElicitation(request, this); } else { return ElicitResult(action: ElicitationAction.decline); } case ElicitationMode.url: if (elicitationUrlSupport != null) { return elicitationUrlSupport.handleElicitation(request, this); } else { return ElicitResult(action: ElicitationAction.decline); } } }); } registerNotificationHandler( PromptListChangedNotification.methodName, _promptListChangedController.sink.add, ); registerNotificationHandler( ToolListChangedNotification.methodName, _toolListChangedController.sink.add, ); registerNotificationHandler( ResourceListChangedNotification.methodName, _resourceListChangedController.sink.add, ); registerNotificationHandler( ResourceUpdatedNotification.methodName, _resourceUpdatedController.sink.add, ); registerNotificationHandler( LoggingMessageNotification.methodName, _logController.sink.add, ); registerNotificationHandler( ElicitationCompleteNotification.methodName, _elicitationCompleteController.sink.add, ); } ``` -------------------------------- ### Invalid Product Data Example (Missing Required Field) Source: https://pub.dev/documentation/dart_mcp/latest/server/ObjectSchema-extension-type.html An example of invalid data due to a missing required field (`productName`). ```json { "productId": "XYZ67890", "price": 9.99 } ``` -------------------------------- ### Get Prompts Source: https://pub.dev/documentation/dart_mcp/latest/server/ListPromptsResult/prompts.html Retrieves a list of all available prompts. ```APIDOC ## GET /prompts ### Description Retrieves a list of all available prompts. ### Method GET ### Endpoint /prompts ### Parameters None ### Request Example None ### Response #### Success Response (200) - **prompts** (List) - A list of Prompt objects. #### Response Example ```json { "prompts": [ { "id": "prompt1", "text": "Example prompt text 1" }, { "id": "prompt2", "text": "Example prompt text 2" } ] } ``` ``` -------------------------------- ### Get Prompts Source: https://pub.dev/documentation/dart_mcp/latest/server/ServerCapabilities/prompts.html Retrieves the current prompt templates if available on the server. ```APIDOC ## GET /prompts ### Description Present if the server offers any prompt templates. ### Method GET ### Endpoint /prompts ### Response #### Success Response (200) - **prompts** (Prompts?) - The prompt templates available on the server. ``` -------------------------------- ### Get Instructions Property Source: https://pub.dev/documentation/dart_mcp/latest/server/InitializeResult/instructions.html Retrieves the instructions string from the internal value map. This property is optional and can be null. ```dart String? get instructions => _value[Keys.instructions] as String?; ``` -------------------------------- ### Initialization and Configuration Source: https://pub.dev/documentation/dart_mcp/latest/server/ResourcesSupport-mixin.html Methods for initializing the client and managing resource templates. ```APIDOC ## POST /websites/pub_dev_dart_mcp/initialize ### Description Invoked by the client as a part of initialization. ### Method POST ### Endpoint /websites/pub_dev_dart_mcp/initialize ### Parameters #### Request Body - **request** (InitializeRequest) - Required - The initialization request object. ### Response #### Success Response (200) - **InitializeResult** - The result of the initialization. ## POST /websites/pub_dev_dart_mcp/handleInitialized ### Description Called by the client after accepting the InitializeResult. ### Method POST ### Endpoint /websites/pub_dev_dart_mcp/handleInitialized ### Parameters #### Request Body - **notification** (InitializedNotification) - Optional - The notification indicating initialization completion. ### Response #### Success Response (200) - **void** - Indicates successful handling of initialization. ## POST /websites/pub_dev_dart_mcp/addResourceTemplate ### Description Adds a ResourceTemplate with a handler. ### Method POST ### Endpoint /websites/pub_dev_dart_mcp/addResourceTemplate ### Parameters #### Request Body - **template** (ResourceTemplate) - Required - The ResourceTemplate to add. - **handler** (ReadResourceHandler) - Required - The handler for the ResourceTemplate. ### Response #### Success Response (200) - **void** - Indicates successful addition of the resource template. ``` -------------------------------- ### GET /websites/pub_dev_dart_mcp/uri Source: https://pub.dev/documentation/dart_mcp/latest/server/Root/uri.html Retrieves the root URI for the Dart MCP. This URI must start with 'file://'. ```APIDOC ## GET /websites/pub_dev_dart_mcp/uri ### Description Retrieves the root URI identifying the MCP. This URI must start with `file://`. ### Method GET ### Endpoint /websites/pub_dev_dart_mcp/uri ### Parameters None ### Request Body None ### Response #### Success Response (200) - **uri** (String) - The root URI, starting with `file://`. #### Response Example { "uri": "file:///path/to/mcp/root" } ``` -------------------------------- ### Get isUntitledSingleSelect Property Source: https://pub.dev/documentation/dart_mcp/latest/server/EnumSchema/isUntitledSingleSelect.html Returns true if the schema type is a string and the enum key is present, indicating an untitled single-select enum. No specific setup is required beyond having a schema object. ```dart bool get isUntitledSingleSelect => type == JsonType.string && _value[Keys.enum_] != null; ``` -------------------------------- ### Get Prompt Method Source: https://pub.dev/documentation/dart_mcp/latest/server/PromptsSupport/getPrompt.html Retrieves the response for a given prompt. It looks up an implementation based on the prompt name and executes it. ```APIDOC ## GET /prompt ### Description Gets the response for a given prompt. ### Method GET ### Endpoint /prompt ### Parameters #### Query Parameters - **name** (string) - Required - The name of the prompt to retrieve. ### Request Example ```json { "name": "example_prompt" } ``` ### Response #### Success Response (200) - **result** (string) - The response generated for the prompt. #### Response Example ```json { "result": "This is the response to the example prompt." } ``` ### Error Handling - **400 Bad Request**: If the prompt name is not found. ``` -------------------------------- ### Get Resources Property Source: https://pub.dev/documentation/dart_mcp/latest/server/ListResourcesResult/resources.html This snippet shows how to access the 'resources' property to get a list of available resources. ```APIDOC ## GET /websites/pub_dev_dart_mcp/resources ### Description Retrieves a list of all available resources. ### Method GET ### Endpoint /websites/pub_dev_dart_mcp/resources ### Parameters None ### Request Body None ### Response #### Success Response (200) - **resources** (List) - A list of Resource objects. #### Response Example ```json { "resources": [ { "id": "resource1", "name": "Example Resource 1" }, { "id": "resource2", "name": "Example Resource 2" } ] } ``` ``` -------------------------------- ### ClientCapabilities Constructor Source: https://pub.dev/documentation/dart_mcp/latest/server/ClientCapabilities/ClientCapabilities.html Provides details on the ClientCapabilities constructor, its parameters, and how to instantiate it. ```APIDOC ## ClientCapabilities Constructor ### Description This section describes the `ClientCapabilities` constructor and its factory constructor `ClientCapabilities.new`. ### Method Constructor ### Endpoint N/A ### Parameters #### Named Parameters - **experimental** (Map?) - Optional - Represents experimental capabilities. - **roots** (RootsCapabilities?) - Optional - Represents root capabilities. - **sampling** (Map?) - Optional - Represents sampling capabilities. - **elicitation** (ElicitationCapability?) - Optional - Represents elicitation capabilities. ### Request Example ```dart final capabilities = ClientCapabilities( experimental: {'feature_x': true}, roots: RootsCapabilities(), ); ``` ### Response #### Success Response (Instance) - **ClientCapabilities** - An instance of the ClientCapabilities class. #### Response Example ```json { "experimental": {"feature_x": true}, "roots": {}, "sampling": null, "elicitation": null } ``` ``` -------------------------------- ### Instructions Property Source: https://pub.dev/documentation/dart_mcp/latest/server/InitializeResult/instructions.html Retrieves instructions describing how to use the server and its features. This information can be used by clients to improve the LLM's understanding of available tools and resources, and may be added to the system prompt. ```APIDOC ## GET /instructions ### Description Retrieves instructions describing how to use the server and its features. This information can be used by clients to improve the LLM's understanding of available tools and resources, and may be added to the system prompt. ### Method GET ### Endpoint /instructions ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **instructions** (String?) - Instructions describing how to use the server and its features. #### Response Example { "instructions": "You can use the following tools: ..." } ``` -------------------------------- ### Implementation Constructor and Properties Source: https://pub.dev/documentation/dart_mcp/latest/server/Implementation-extension-type.html Details on how to construct an Implementation object and its available properties. ```APIDOC ## Implementation Extension Type Describes the name and version of an MCP implementation. ### Constructors * **Implementation** (`{required String name, required String version, String? title, String? description, List? icons, String? websiteUrl}`) * Creates a new Implementation object. * **Implementation.fromMap** (`Map _value`) * Creates an Implementation object from a map. ### Properties * **description** (`String?`) * A human-readable description of what this implementation does. * **icons** (`List?`) * Optional set of sized icons that the client can display in a user interface. * **name** (`String`) * Intended for programmatic or logical use, but used as a display name in past specs for fallback (if title isn't present). * **title** (`String?`) * A short title for this object. * **version** (`String`) * The version of the implementation. * **websiteUrl** (`String?`) * Optional URL to the website of the implementation. ``` -------------------------------- ### Prompt Implementation Source: https://pub.dev/documentation/dart_mcp/latest/server/Prompt/Prompt.html Shows the implementation of the Prompt factory constructor. ```APIDOC ## Prompt Implementation ### Description This section details the implementation of the `Prompt` factory constructor. It maps the provided parameters to a `Map` which is then used to create the `Prompt` object. ### Method Factory Constructor Implementation ### Endpoint N/A (Dart Class Constructor) ### Parameters See the 'Prompt Constructor' section for parameter details. ### Request Example ```dart // The factory constructor itself is the implementation example. factory Prompt({ required String name, String? title, String? description, List? arguments, List? icons, Meta? meta, }) => Prompt.fromMap({ Keys.name: name, if (title != null) Keys.title: title, if (description != null) Keys.description: description, if (arguments != null) Keys.arguments: arguments, if (icons != null) Keys.icons: icons, if (meta != null) Keys.meta: meta, }); ``` ### Response #### Success Response (200) N/A (This is a constructor implementation, not an API endpoint response) #### Response Example N/A ``` -------------------------------- ### Get Object's Runtime Type Source: https://pub.dev/documentation/dart_mcp/latest/client/RootsSupport/runtimeType.html Use the runtimeType property to get the runtime type of an object. This is an external getter and cannot be directly implemented. ```dart external Type get runtimeType; ``` -------------------------------- ### Invalid Product Data Example (Extra Property) Source: https://pub.dev/documentation/dart_mcp/latest/server/ObjectSchema-extension-type.html An example of invalid data due to an undefined property (`color`) when `additionalProperties` is set to false in the schema. ```json { "productId": "DEF4567", "productName": "Another Gadget", "color": "blue" // Invalid if additionalProperties is false } ``` -------------------------------- ### Custom noSuchMethod Implementation Example Source: https://pub.dev/documentation/dart_mcp/latest/server/PromptsSupport/noSuchMethod.html This example demonstrates how a class can override noSuchMethod to provide custom behavior, such as logging invocations, without implementing all interface methods. ```APIDOC ## Custom noSuchMethod Implementation ### Description This example shows a `MockList` class that overrides `noSuchMethod` to log invocations and then calls the superclass's `noSuchMethod`. ### Method `noSuchMethod` ### Endpoint N/A (Instance method) ### Request Example ```dart class MockList implements List { @override dynamic noSuchMethod(Invocation invocation) { print('Invocation: $invocation'); return super.noSuchMethod(invocation); // Will throw. } } void main() { MockList().add(42); } ``` ### Response #### Success Response (200) - **dynamic** - The result of the `super.noSuchMethod(invocation)` call, which typically throws a `NoSuchMethodError` in this case. #### Response Example ``` Invocation: Invocation.method(#add, [42]) ``` ### Notes - Calls to `List` methods are forwarded to `noSuchMethod`. - This allows the `MockList` class to function without concrete implementations of `List` interface methods. ``` -------------------------------- ### Root Constructor and Factory Method Source: https://pub.dev/documentation/dart_mcp/latest/server/Root/Root.html Details the parameters for the Root constructor and provides an example of using the factory method to create a Root object. ```APIDOC ## Root Constructor ### Description Represents the constructor for the Root class, allowing initialization with required and optional parameters. ### Parameters #### Constructor Parameters - **uri** (String) - Required - The URI for the root object. - **name** (String?) - Optional - The name for the root object. - **meta** (Meta?) - Optional - Metadata associated with the root object. ### Implementation #### Factory Method: Root.fromMap This factory method constructs a Root object from a map, handling optional parameters. ```dart factory Root({required String uri, String? name, Meta? meta}) => Root.fromMap({ Keys.uri: uri, if (name != null) Keys.name: name, if (meta != null) Keys.meta: meta, }); ``` ### Request Example ```json { "uri": "https://example.com", "name": "Example Root", "meta": { "key": "value" } } ``` ### Response Example ```json { "uri": "https://example.com", "name": "Example Root", "meta": { "key": "value" } } ``` ``` -------------------------------- ### Initialize Server Method Implementation Source: https://pub.dev/documentation/dart_mcp/latest/client/ServerConnection/initialize.html This method initializes the server and must be called before any other operations. It handles server version checks and potential shutdown if the protocol version is not supported. Consider passing a `protocolLogSink` for debugging connection issues. ```dart Future initialize(InitializeRequest request) async { final response = await sendRequest( InitializeRequest.methodName, request, ); serverInfo = response.serverInfo; serverCapabilities = response.capabilities; final serverVersion = response.protocolVersion; if (serverVersion == null || !serverVersion.isSupported) { await shutdown(); } else { protocolVersion = serverVersion; } return response; } ``` -------------------------------- ### Get Meta Property Source: https://pub.dev/documentation/dart_mcp/latest/server/Result/meta.html Retrieves the meta property value. ```APIDOC ## GET /meta ### Description Retrieves the meta property value from the system. ### Method GET ### Endpoint /meta ### Parameters None ### Request Example None ### Response #### Success Response (200) - **meta** (Meta) - The meta property value. #### Response Example ```json { "meta": { ... } } ``` ``` -------------------------------- ### Initialize MCPClient with Implementation Source: https://pub.dev/documentation/dart_mcp/latest/client/MCPClient/MCPClient.html Use this constructor to create an MCPClient instance. It requires an 'implementation' object and calls the 'initialize' method upon creation. ```dart MCPClient(this.implementation) { initialize(); } ``` -------------------------------- ### RootsCapabilities.fromMap Constructor Source: https://pub.dev/documentation/dart_mcp/latest/server/RootsCapabilities/RootsCapabilities.fromMap.html This snippet shows how to use the RootsCapabilities.fromMap constructor. ```APIDOC ## RootsCapabilities.fromMap constructor ### Description Creates a RootsCapabilities object from a map. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **_value** (Map) - Required - The map to create the RootsCapabilities object from. ### Request Example ```json { "_value": { "some_key": "some_value" } } ``` ### Response #### Success Response (200) - **RootsCapabilities** - The created RootsCapabilities object. #### Response Example ```json { "example": "RootsCapabilities object" } ``` ``` -------------------------------- ### Get Resource Templates Source: https://pub.dev/documentation/dart_mcp/latest/server/ListResourceTemplatesResult/resourceTemplates.html Retrieves a list of all available resource templates. ```APIDOC ## GET /websites/pub_dev_dart_mcp/resourceTemplates ### Description Retrieves a list of all available resource templates. ### Method GET ### Endpoint /websites/pub_dev_dart_mcp/resourceTemplates ### Response #### Success Response (200) - **resourceTemplates** (List) - A list of ResourceTemplate objects. ``` -------------------------------- ### Server Initialization and Management API Source: https://pub.dev/documentation/dart_mcp/latest/server/PromptsSupport-mixin.html Methods related to server initialization, capabilities, and general management. ```APIDOC ## POST /api/initialize ### Description Initializes the server, allowing mixins to register their methods and adjust capabilities. ### Method POST ### Endpoint /api/initialize ### Parameters #### Request Body - **request** (InitializeRequest) - Required - The initialization request object. ### Response #### Success Response (200) - **InitializeResult** - The result of the initialization, including server capabilities. ## POST /api/createMessage ### Description A request to prompt the LLM owned by the client with a message. ### Method POST ### Endpoint /api/createMessage ### Parameters #### Request Body - **request** (CreateMessageRequest) - Required - The request object for creating a message. ### Response #### Success Response (200) - **CreateMessageResult** - The result of creating the message. ## GET /api/roots/list ### Description Lists all the root URIs from the client. ### Method GET ### Endpoint /api/roots/list ### Parameters #### Query Parameters - **request** (ListRootsRequest) - Optional - The request object for listing roots. ### Response #### Success Response (200) - **ListRootsResult** - An object containing the list of root URIs. ## POST /api/progress/notify ### Description Notifies the peer of progress towards completing some request. ### Method POST ### Endpoint /api/progress/notify ### Parameters #### Request Body - **notification** (ProgressNotification) - Required - The progress notification object. ## POST /api/ping ### Description Pings the peer and returns whether or not it responded within the specified timeout. ### Method POST ### Endpoint /api/ping ### Parameters #### Query Parameters - **timeout** (Duration) - Optional - The timeout duration for the ping. Defaults to 1 second. #### Request Body - **request** (PingRequest) - Optional - The ping request object. ### Response #### Success Response (200) - **bool** - True if the peer responded within the timeout, false otherwise. ## POST /api/notifications/send ### Description Sends a notification to the peer. ### Method POST ### Endpoint /api/notifications/send ### Parameters #### Request Body - **method** (String) - Required - The name of the notification method. - **notification** (Notification) - Optional - The notification payload. ## POST /api/requests/send ### Description Sends a request to the peer and handles coercing the response to the specified type. ### Method POST ### Endpoint /api/requests/send ### Parameters #### Request Body - **methodName** (String) - Required - The name of the method to call. - **request** (Request) - Optional - The request payload. ### Response #### Success Response (200) - **T** - The result of the request, coerced to type T. ## POST /api/shutdown ### Description Handles cleanup of all streams and other resources on shutdown. ### Method POST ### Endpoint /api/shutdown ### Response #### Success Response (200) - **Future** - A future that completes when shutdown is finished. ``` -------------------------------- ### ProgressToken Property Access Source: https://pub.dev/documentation/dart_mcp/latest/server/WithProgressToken/progressToken.html This snippet shows how to get the value of the progressToken property. ```APIDOC ## GET /websites/pub_dev_dart_mcp/progressToken ### Description Retrieves the current progress token. ### Method GET ### Endpoint /websites/pub_dev_dart_mcp/progressToken ### Parameters None ### Request Example None ### Response #### Success Response (200) - **progressToken** (ProgressToken?) - The current progress token, or null if not set. #### Response Example ```json { "progressToken": null } ``` ## Implementation Details ### Description This section details the internal implementation of the `progressToken` getter. ### Method Getter ### Endpoint Internal ### Parameters None ### Request Example None ### Response #### Success Response (200) - **progressToken** (ProgressToken?) - The value retrieved from the internal `_value` map. #### Response Example ```dart ProgressToken? get progressToken => _value[Keys.progressToken] as ProgressToken?; ``` ``` -------------------------------- ### minProperties Property Getter Source: https://pub.dev/documentation/dart_mcp/latest/server/ObjectSchema/minProperties.html This snippet shows how to get the value of the minProperties property. ```APIDOC ## GET minProperties ### Description Retrieves the minimum number of properties required for an object to be valid. ### Method GET ### Endpoint `/websites/pub_dev_dart_mcp/minProperties` ### Parameters None ### Response #### Success Response (200) - **minProperties** (int?) - The minimum number of properties required. #### Response Example ```json { "minProperties": 1 } ``` ``` -------------------------------- ### MCPClient Constructors Source: https://pub.dev/documentation/dart_mcp/latest/client/MCPClient-class.html Details on how to construct an MCPClient instance. ```APIDOC ## Constructors ### MCPClient ```dart MCPClient(Implementation implementation) ``` **Parameters** * **implementation** (Implementation) - A description of the client sent to servers during initialization. ``` -------------------------------- ### Icon Constructor Source: https://pub.dev/documentation/dart_mcp/latest/server/Icon/Icon.html Details the parameters for creating an Icon object. ```APIDOC ## Icon Constructor ### Description Creates a new Icon object. ### Parameters #### Constructor Parameters - **src** (String) - Required - The source path for the icon. - **mimeType** (String) - Optional - The MIME type of the icon file. - **sizes** (List) - Optional - A list of available sizes for the icon. - **theme** (IconTheme) - Optional - The theme associated with the icon. ``` -------------------------------- ### Get Maximum Property Source: https://pub.dev/documentation/dart_mcp/latest/server/NumberSchema/maximum.html Retrieves the maximum allowed value for a number property. ```APIDOC ## GET /websites/pub_dev_dart_mcp/maximum ### Description Retrieves the maximum value (inclusive) for a number property. ### Method GET ### Endpoint /websites/pub_dev_dart_mcp/maximum ### Parameters #### Query Parameters - **num** (num) - Optional - The number property to query. ### Response #### Success Response (200) - **maximum** (num) - The maximum value (inclusive) for the number property. ### Response Example ```json { "maximum": 100 } ``` ``` -------------------------------- ### Get Logging Level Source: https://pub.dev/documentation/dart_mcp/latest/server/LoggingMessageNotification/level.html Retrieves the current severity level of log messages. ```APIDOC ## GET /logging/level ### Description Retrieves the current severity level of log messages. ### Method GET ### Endpoint /logging/level ### Response #### Success Response (200) - **level** (LoggingLevel) - The current logging level. #### Response Example ```json { "level": "info" } ``` ``` -------------------------------- ### GetPromptRequest Constructor Source: https://pub.dev/documentation/dart_mcp/latest/server/GetPromptRequest/GetPromptRequest.html Provides details on the GetPromptRequest constructor, its parameters, and how to use the factory constructor to create an instance. ```APIDOC ## GetPromptRequest Constructor ### Description This section describes the `GetPromptRequest` constructor and its factory implementation. ### Method Factory Constructor ### Endpoint N/A (Dart Class Constructor) ### Parameters #### Constructor Parameters - **name** (String) - Required - The name for the prompt request. - **arguments** (Map?) - Optional - Additional arguments for the prompt request. - **meta** (MetaWithProgressToken?) - Optional - Metadata for tracking progress. ### Request Example ```dart final promptRequest = GetPromptRequest( name: 'example_prompt', arguments: {'key': 'value'}, meta: MetaWithProgressToken(), ); ``` ### Response #### Success Response Returns an instance of `GetPromptRequest`. #### Response Example ```dart // Example of a GetPromptRequest object structure (internal representation) { "name": "example_prompt", "arguments": {"key": "value"}, "meta": { /* ... MetaWithProgressToken details ... */ } } ``` ``` -------------------------------- ### Prompts Constructor and Properties Source: https://pub.dev/documentation/dart_mcp/latest/server/Prompts-extension-type.html Details on how to create and use the Prompts object, including its constructors and properties. ```APIDOC ## Prompts Extension Type Prompts parameter for ServerCapabilities. * Map ### Constructors * **Prompts**({bool? listChanged}) * **factory Prompts.fromMap**(Map _value) ### Properties * **listChanged** ↔ bool? Whether this server supports notifications for changes to the prompt list. getter/setter pair ``` -------------------------------- ### URL Property - Get Source: https://pub.dev/documentation/dart_mcp/latest/server/ElicitationCapability/url.html Retrieves the current setting for URL-based elicitation support. ```APIDOC ## GET /websites/pub_dev_dart_mcp/url ### Description Retrieves whether URL-based elicitation is supported. ### Method GET ### Endpoint /websites/pub_dev_dart_mcp/url ### Response #### Success Response (200) - **url** (Map?) - Indicates if URL-based elicitation is supported. ``` -------------------------------- ### StringSchema Constructors Source: https://pub.dev/documentation/dart_mcp/latest/server/StringSchema-extension-type.html Details on how to create instances of StringSchema. ```APIDOC ## StringSchema Constructors ### `StringSchema()` Creates a new StringSchema instance with optional configuration. **Parameters:** - `title` (String?): A title for this schema. - `description` (String?): A description of this schema. - `minLength` (int?): The minimum allowed length of this String. - `maxLength` (int?): The maximum allowed length of this String. - `pattern` (String?): A regular expression pattern that the String must match. - `defaultValue` (String?): The default value for this schema. - `format` (StringFormat?): The format of this String. - `enumValues` (@Deprecated('Use UntitledSingleSelectEnumSchema instead.') Iterable?): The allowed values for this String. ### `StringSchema.fromMap(Map _value)` Creates a StringSchema instance from a map representation. ``` -------------------------------- ### Get requestedSchema Property Source: https://pub.dev/documentation/dart_mcp/latest/server/ElicitRequest/requestedSchema.html Retrieves the requestedSchema from the internal value. This is required for ElicitationMode.form. ```dart ObjectSchema? get requestedSchema => _value[Keys.requestedSchema] as ObjectSchema?; ``` -------------------------------- ### Initialize ClientCapabilities Source: https://pub.dev/documentation/dart_mcp/latest/client/ElicitationUrlSupport/capabilities.html Instantiate the ClientCapabilities class. This can be modified by overriding the initialize method. ```dart final ClientCapabilities capabilities = ClientCapabilities(); ``` -------------------------------- ### Initialize Method Source: https://pub.dev/documentation/dart_mcp/latest/server/MCPServer/initialize.html Initializes the Dart MCP by processing the InitializeRequest and setting up server capabilities and client information. ```APIDOC ## POST /initialize ### Description Initializes the Dart MCP. Mixins should register their methods in this method, as well as editing the InitializeResult.capabilities as needed. ### Method POST ### Endpoint /initialize ### Parameters #### Request Body - **request** (InitializeRequest) - Required - The request object containing initialization parameters. - **protocolVersion** (ProtocolVersion) - Optional - The client's protocol version. - **capabilities** (ClientCapabilities) - Optional - The client's capabilities. - **clientInfo** (ClientInfo) - Optional - Information about the client. ### Request Example ```json { "protocolVersion": "3.0", "capabilities": { "roots": { "listChanged": true } }, "clientInfo": { "name": "MyClient", "version": "1.0" } } ``` ### Response #### Success Response (200) - **protocolVersion** (ProtocolVersion) - The server's supported protocol version. - **serverCapabilities** (ServerCapabilities) - The server's capabilities. - **serverInfo** (ServerInfo) - Information about the server implementation. - **instructions** (Instructions) - Instructions for the client. #### Response Example ```json { "protocolVersion": "3.0", "serverCapabilities": {}, "serverInfo": {}, "instructions": {} } ``` ``` -------------------------------- ### Get maxLength Property Source: https://pub.dev/documentation/dart_mcp/latest/server/StringSchema/maxLength.html Retrieves the maximum allowed length of a String. This is an implementation detail. ```dart int? get maxLength => _value[Keys.maxLength] as int?; ``` -------------------------------- ### Get Properties Source: https://pub.dev/documentation/dart_mcp/latest/server/ObjectSchema/properties.html Retrieves a map of properties for an object, where each property is associated with its nested Schema. ```APIDOC ## GET /websites/pub_dev_dart_mcp/properties ### Description Retrieves a map of the properties of the object to the nested Schemas for those properties. ### Method GET ### Endpoint /websites/pub_dev_dart_mcp/properties ### Parameters #### Query Parameters - **dark_mode** (boolean) - Optional - Specifies if dark mode is enabled. ### Response #### Success Response (200) - **properties** (Map) - A map where keys are property names (String) and values are their corresponding Schemas. ### Response Example ```json { "properties": { "propertyName1": { "type": "string" }, "propertyName2": { "type": "integer" } } } ``` ``` -------------------------------- ### ImageContent Implementation Source: https://pub.dev/documentation/dart_mcp/latest/server/ImageContent/ImageContent.html This section shows the implementation of the ImageContent factory constructor, demonstrating how it maps the provided parameters to a map for internal object creation. ```APIDOC ## ImageContent Implementation ### Description This is the implementation of the `ImageContent.new` factory constructor, which takes required `data` and `mimeType`, and optional `annotations` and `meta` to construct an `ImageContent` object. ### Method Factory Constructor Implementation ### Endpoint N/A (Constructor implementation) ### Parameters - **data** (String) - Required - The image data. - **mimeType** (String) - Required - The MIME type of the image. - **annotations** (Annotations?) - Optional - Annotations for the image. - **meta** (Meta?) - Optional - Metadata for the image. ### Request Example ```dart ImageContent( data: 'base64EncodedImageData', mimeType: 'image/png', annotations: Annotations(label: 'cat'), meta: Meta(timestamp: DateTime.parse('2023-10-27T10:00:00Z')), ) ``` ### Response #### Success Response (200) N/A (Constructor implementation) #### Response Example N/A (Constructor implementation) ``` -------------------------------- ### Get Context Property Source: https://pub.dev/documentation/dart_mcp/latest/server/CompleteRequest/context.html Retrieves the optional context for completions. This property is of type CompletionContext. ```dart CompletionContext? get context => _value[Keys.context] as CompletionContext?; ``` -------------------------------- ### Initialization API Source: https://pub.dev/documentation/dart_mcp/latest/client/ServerConnection-class.html APIs related to initializing and managing the server connection. ```APIDOC ## POST /initialize ### Description Initializes the server. This method must be called before any other operations. ### Method POST ### Endpoint /initialize ### Request Body - **request** (InitializeRequest) - Required - The request object for initialization. ### Response #### Success Response (200) - **InitializeResult** (InitializeResult) - The result of the initialization. ## POST /notifyInitialized ### Description Called after a successful call to initialize to notify the peer. ### Method POST ### Endpoint /notifyInitialized ### Request Body - **notification** (InitializedNotification) - Optional - The notification object. ### Response #### Success Response (200) void - Indicates successful notification. ## POST /shutdown ### Description Closes all connections and streams, allowing the process to exit cleanly. ### Method POST ### Endpoint /shutdown ### Response #### Success Response (200) void - Indicates successful shutdown. ``` -------------------------------- ### Get Annotations Source: https://pub.dev/documentation/dart_mcp/latest/server/Annotated/annotations.html Retrieves the annotations associated with the object. Returns null if no annotations are present. ```APIDOC ## GET /websites/pub_dev_dart_mcp/annotations ### Description Retrieves the annotations for this object. ### Method GET ### Endpoint /websites/pub_dev_dart_mcp/annotations ### Parameters None ### Request Body None ### Response #### Success Response (200) - **annotations** (Annotations?) - Annotations for this object. #### Response Example ```json { "annotations": { "key1": "value1", "key2": "value2" } } ``` ``` -------------------------------- ### connectServer Method Source: https://pub.dev/documentation/dart_mcp/latest/client/ElicitationFormSupport/connectServer.html Establishes a connection to an MCP server using a pre-established StreamChannel. It allows for optional logging of protocol messages. ```APIDOC ## POST /connectServer ### Description Establishes a connection to an MCP server using a provided `StreamChannel`. Optionally logs all sent and received messages to a `protocolLogSink`. ### Method POST ### Endpoint /connectServer ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **channel** (StreamChannel) - Required - The established stream channel for communication. - **protocolLogSink** (Sink?) - Optional - A sink to which all protocol messages will be forwarded. Incoming messages are prefixed with `<<<` and outgoing messages with `>>>`. The caller is responsible for closing this sink. ### Request Example ```json { "channel": ">", "protocolLogSink": ">" } ``` ### Response #### Success Response (200) - **ServerConnection** (object) - An object representing the established server connection. #### Response Example ```json { "connection": "" } ``` ``` -------------------------------- ### ServerCapabilities Factory Constructor Implementation Source: https://pub.dev/documentation/dart_mcp/latest/server/ServerCapabilities/ServerCapabilities.html Shows the implementation of the ServerCapabilities factory constructor, which maps provided arguments to a new ServerCapabilities instance. ```APIDOC ## ServerCapabilities Factory Constructor Implementation ### Description This factory constructor, `ServerCapabilities.new`, creates a `ServerCapabilities` instance by mapping the provided optional parameters to their corresponding keys. It only includes parameters that are not null. ### Method Factory Constructor ### Endpoint N/A (Constructor) ### Parameters #### Optional Parameters - **experimental** (Map?) - Optional - Configuration for experimental features. - **completions** (Completions?) - Optional - Configuration for completions. - **logging** (Logging?) - Optional - Configuration for logging. - **prompts** (Prompts?) - Optional - Configuration for prompts. - **resources** (Resources?) - Optional - Configuration for resources. - **tools** (Tools?) - Optional - Configuration for tools. - **elicitation** (Elicitation?) - Deprecated - Do not use, only clients have this capability. ### Request Example ```dart final serverCapabilities = ServerCapabilities( experimental: {'feature_x': true}, logging: Logging(level: 'debug'), ); ``` ### Response #### Success Response (Instance of ServerCapabilities) - **experimental** (Map?) - Configuration for experimental features. - **completions** (Completions?) - Configuration for completions. - **logging** (Logging?) - Configuration for logging. - **prompts** (Prompts?) - Configuration for prompts. - **resources** (Resources?) - Configuration for resources. - **tools** (Tools?) - Configuration for tools. - **elicitation** (Elicitation?) - Deprecated - Configuration for elicitation. #### Response Example ```dart ServerCapabilities({ 'experimental': {'feature_x': true}, 'logging': Logging(level: 'debug'), }); ``` ``` -------------------------------- ### Get Prompt Method Source: https://pub.dev/documentation/dart_mcp/latest/client/ServerConnection/getPrompt.html Retrieves a prompt from the server using the provided request object. ```APIDOC ## POST /getPrompt ### Description Gets the requested Prompt from the server. ### Method POST ### Endpoint /getPrompt ### Parameters #### Request Body - **request** (GetPromptRequest) - Required - The request object containing details for fetching the prompt. ### Request Example ```json { "request": "GetPromptRequest object" } ``` ### Response #### Success Response (200) - **GetPromptResult** (GetPromptResult) - The result of the prompt retrieval. #### Response Example ```json { "result": "GetPromptResult object" } ``` ``` -------------------------------- ### Get readOnlyHint Property Source: https://pub.dev/documentation/dart_mcp/latest/server/ToolAnnotations/readOnlyHint.html Retrieves the value of the readOnlyHint property. If true, the tool does not modify its environment. ```dart bool? get readOnlyHint => _value[Keys.readOnlyHint] as bool?; ``` -------------------------------- ### Prompt.fromMap Constructor Source: https://pub.dev/documentation/dart_mcp/latest/server/Prompt/Prompt.fromMap.html This snippet details the Prompt.fromMap constructor, which takes a Map as input to create a Prompt object. ```APIDOC ## Prompt.fromMap Constructor ### Description Creates a Prompt object from a map of string keys to object values. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **_value** (Map) - Required - A map containing the prompt data. ### Request Example ```json { "_value": { "prompt_text": "This is a sample prompt.", "parameters": { "temperature": 0.7 } } } ``` ### Response #### Success Response (200) - **Prompt** (object) - A newly created Prompt object. #### Response Example ```json { "prompt_text": "This is a sample prompt.", "parameters": { "temperature": 0.7 } } ``` ``` -------------------------------- ### Initialize Method Implementation Source: https://pub.dev/documentation/dart_mcp/latest/server/MCPServer/initialize.html Mixins should register their methods and edit capabilities in this method. It handles protocol version negotiation and client capability registration. ```dart @mustCallSuper /// Mixins should register their methods in this method, as well as editing /// the [InitializeResult.capabilities] as needed. FutureOr initialize(InitializeRequest request) { // If we don't support or understand the version, set it to the latest one // that we do support. If the client doesn't support that version they will // terminate the connection. final clientProtocolVersion = request.protocolVersion; if (clientProtocolVersion == null || !clientProtocolVersion.isSupported) { protocolVersion = ProtocolVersion.latestSupported; } else { protocolVersion = clientProtocolVersion; } clientCapabilities = request.capabilities; if (clientCapabilities.roots?.listChanged == true) { _rootsListChangedController = StreamController.broadcast(); registerNotificationHandler( RootsListChangedNotification.methodName, _rootsListChangedController!.sink.add, ); } clientInfo = request.clientInfo; assert(!_initialized.isCompleted); return InitializeResult( protocolVersion: protocolVersion, serverCapabilities: ServerCapabilities(), serverInfo: implementation, instructions: instructions, ); } ``` -------------------------------- ### Get Progress Value Source: https://pub.dev/documentation/dart_mcp/latest/server/ProgressNotification/progress.html Retrieves the current progress value. This property should increase as progress is made. ```dart num get progress => _value[Keys.progress] as num; ``` -------------------------------- ### AudioContent Constructors Source: https://pub.dev/documentation/dart_mcp/latest/server/AudioContent-extension-type.html Information on how to construct an AudioContent object. ```APIDOC ## Constructors ### AudioContent ```dart AudioContent({required String data, required String mimeType, Annotations? annotations, Meta? meta}) ``` ### AudioContent.fromMap ```dart factory AudioContent.fromMap(Map _value) ``` ``` -------------------------------- ### Accessing Server Capabilities Source: https://pub.dev/documentation/dart_mcp/latest/server/InitializeResult/capabilities.html This snippet shows how to get the ServerCapabilities object using the `capabilities` getter. ```APIDOC ## GET /websites/pub_dev_dart_mcp/capabilities ### Description Retrieves the server capabilities object. ### Method GET ### Endpoint /websites/pub_dev_dart_mcp/capabilities ### Parameters None ### Request Body None ### Response #### Success Response (200) - **capabilities** (ServerCapabilities) - An object containing the server's capabilities. #### Response Example ```json { "capabilities": { ... } } ``` ``` -------------------------------- ### MCPClient Constructor Source: https://pub.dev/documentation/dart_mcp/latest/client/MCPClient/MCPClient.html This snippet shows the constructor for the MCPClient class, which takes an 'implementation' object as a parameter and initializes the client. ```APIDOC ## MCPClient Constructor ### Description Initializes a new instance of the MCPClient class. ### Parameters #### Request Body - **implementation** (Implementation) - Required - The implementation object to be used by the MCPClient. ### Request Example ```dart final mcpClient = MCPClient(myImplementation); ``` ### Response #### Success Response (200) - **MCPClient** (object) - An instance of the MCPClient. #### Response Example ```json { "message": "MCPClient initialized successfully" } ``` ``` -------------------------------- ### Get ServerCapabilities Source: https://pub.dev/documentation/dart_mcp/latest/server/InitializeResult/capabilities.html Accesses the capabilities property from the _value map. Ensure _value is initialized before calling this. ```dart ServerCapabilities get capabilities => _value[Keys.capabilities] as ServerCapabilities; ``` -------------------------------- ### Resource Constructor Source: https://pub.dev/documentation/dart_mcp/latest/server/Resource/Resource.html Details the parameters for creating a Resource object. ```APIDOC ## Resource Constructor ### Description This section describes the `Resource` constructor, which is used to create Resource objects with various properties. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **uri** (String) - Required - The URI of the resource. - **name** (String) - Required - The name of the resource. - **annotations** (Annotations?) - Optional - Annotations associated with the resource. - **description** (String?) - Optional - A description of the resource. - **mimeType** (String?) - Optional - The MIME type of the resource. - **size** (int?) - Optional - The size of the resource. - **meta** (Meta?) - Optional - Metadata associated with the resource. - **icons** (List?) - Optional - A list of icons for the resource. ### Request Example ```json { "uri": "http://example.com/resource", "name": "Example Resource", "description": "This is an example resource.", "mimeType": "application/json", "size": 1024, "annotations": {}, "meta": {}, "icons": [] } ``` ### Response #### Success Response (200) This constructor does not directly return a response in the typical API sense. It creates an instance of the `Resource` class. #### Response Example (Instance of Resource class) ``` -------------------------------- ### Get Version Property Source: https://pub.dev/documentation/dart_mcp/latest/server/Implementation/version.html Retrieves the version string. Throws an ArgumentError if the version field is missing. ```APIDOC ## GET /version ### Description Retrieves the version string of the implementation. This property is expected to be a String. ### Method GET ### Endpoint /version ### Parameters None ### Request Body None ### Response #### Success Response (200) - **version** (String) - The version string of the implementation. #### Response Example { "version": "1.0.0" } #### Error Response (400) - **error** (String) - "Missing version field in Implementation." #### Error Response Example { "error": "Missing version field in Implementation." } ```