> ## Documentation Index
> Fetch the complete documentation index at: https://ai.easyaf.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# McpServer

> Extension methods for McpServer from ModelContextProtocol.Core

## Definition

**Assembly:** ModelContextProtocol.Core.dll

**Namespace:** ModelContextProtocol.Server

## Syntax

```csharp theme={"dark"}
ModelContextProtocol.Server.McpServer
```

## Summary

This type is defined in ModelContextProtocol.Core.

## Methods

### &#x20;ElicitAsync Extension

> [!NOTE]
>
> Extension method from `ModelContextProtocol.Server.McpEssentials_Core_McpServerExtensions`

Builds *form* and elicits it from the client.

#### Syntax

```csharp theme={"dark"}
public static System.Threading.Tasks.ValueTask<ModelContextProtocol.Protocol.ElicitResult> ElicitAsync(ModelContextProtocol.Server.McpServer server, CloudNimble.McpEssentials.Core.Tasks.Elicitations.IFormElicitationSource form, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `server` | `ModelContextProtocol.Server.McpServer` | The MCP server. |
| `form` | `CloudNimble.McpEssentials.Core.Tasks.Elicitations.IFormElicitationSource` | A form builder or field facade. |
| `cancellationToken` | `System.Threading.CancellationToken` | The cancellation token. |

#### Returns

Type: `System.Threading.Tasks.ValueTask<ModelContextProtocol.Protocol.ElicitResult>`
The untyped elicitation result.

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *server* or *form* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

#### Examples

Metadata-driven tools keep the builder and add a field per property name:

```csharp theme={"dark"}
var form = FormElicitation.Create($"How should we query {entitySet}?");
form.String("filter").Title("$filter");
form.Integer("top").Title("$top").Min(1).Max(1000).Default(20);
var result = await server.ElicitAsync(form, cancellationToken);
```

### &#x20;ElicitAsync Extension

> [!NOTE]
>
> Extension method from `ModelContextProtocol.Server.McpEssentials_Core_McpServerExtensions`

Builds *form*, elicits it, and deserializes accepted content as *T*.

#### Syntax

```csharp theme={"dark"}
public static System.Threading.Tasks.ValueTask<ModelContextProtocol.Protocol.ElicitResult<T>> ElicitAsync<T>(ModelContextProtocol.Server.McpServer server, CloudNimble.McpEssentials.Core.Tasks.Elicitations.IFormElicitationSource<T> form, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `server` | `ModelContextProtocol.Server.McpServer` | The MCP server. |
| `form` | `CloudNimble.McpEssentials.Core.Tasks.Elicitations.IFormElicitationSource<T>` | A typed form builder or field facade. |
| `cancellationToken` | `System.Threading.CancellationToken` | The cancellation token. |

#### Returns

Type: `System.Threading.Tasks.ValueTask<ModelContextProtocol.Protocol.ElicitResult<T>>`
The typed elicitation result.

#### Type Parameters

* `T` - The form type. Inferred from `String)`.

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *server* or *form* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

#### Examples

```csharp theme={"dark"}
var result = await server.ElicitAsync(
    FormElicitation.From&lt;ProductQuery&gt;("Query products").Exclude(x =&gt; x.Skip),
    cancellationToken);
if (result.IsAccepted) { Use(result.Content); }
```

### &#x20;ElicitAsync Extension

> [!NOTE]
>
> Extension method from `ModelContextProtocol.Server.McpEssentials_Core_McpServerExtensions`

Builds an untyped *form*, elicits it, and deserializes accepted content as *T*.

#### Syntax

```csharp theme={"dark"}
public static System.Threading.Tasks.ValueTask<ModelContextProtocol.Protocol.ElicitResult<T>> ElicitAsync<T>(ModelContextProtocol.Server.McpServer server, CloudNimble.McpEssentials.Core.Tasks.Elicitations.IFormElicitationSource form, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `server` | `ModelContextProtocol.Server.McpServer` | The MCP server. |
| `form` | `CloudNimble.McpEssentials.Core.Tasks.Elicitations.IFormElicitationSource` | A form built field-by-field, typically from metadata. |
| `cancellationToken` | `System.Threading.CancellationToken` | The cancellation token. |

#### Returns

Type: `System.Threading.Tasks.ValueTask<ModelContextProtocol.Protocol.ElicitResult<T>>`
The typed elicitation result.

#### Type Parameters

* `T` - The CLR type to bind accepted content onto.

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *server* or *form* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

### &#x20;ElicitAsync Extension

> [!NOTE]
>
> Extension method from `ModelContextProtocol.Server.McpEssentials_Core_McpServerExtensions`

Builds *form*, elicits it, and deserializes accepted content as *T*
using *options*.

#### Syntax

```csharp theme={"dark"}
public static System.Threading.Tasks.ValueTask<ModelContextProtocol.Protocol.ElicitResult<T>> ElicitAsync<T>(ModelContextProtocol.Server.McpServer server, CloudNimble.McpEssentials.Core.Tasks.Elicitations.IFormElicitationSource form, System.Text.Json.JsonSerializerOptions options, System.Threading.CancellationToken cancellationToken = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `server` | `ModelContextProtocol.Server.McpServer` | The MCP server. |
| `form` | `CloudNimble.McpEssentials.Core.Tasks.Elicitations.IFormElicitationSource` | Any form source, including an untyped builder filled from metadata. |
| `options` | `System.Text.Json.JsonSerializerOptions?` | Serializer options. When [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), properties are camelCase and enums use their member names. |
| Native AOT callers should pass options from a [JsonSerializerContext](https://learn.microsoft.com/dotnet/api/system.text.json.serialization.jsonserializercontext). | | |
| `cancellationToken` | `System.Threading.CancellationToken` | The cancellation token. |

#### Returns

Type: `System.Threading.Tasks.ValueTask<ModelContextProtocol.Protocol.ElicitResult<T>>`
The typed elicitation result.

#### Type Parameters

* `T` - The form type.

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *server* or *form* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

#### Remarks

Use this overload when the form was built from string field names (EDM properties, query options)
and you still want a CLR DTO back.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.