> ## 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.

# ToolsMcpSessionHolder

> A mutable slot for the one [ODataMcpSession](/odata-mcp/api-reference/Microsoft/OData/Mcp/Core/Catalog/ODataMcpSession) a Tools host serves, registered before the host...

## Definition

**Assembly:** Microsoft.OData.Mcp.Tools.dll

**Namespace:** Microsoft.OData.Mcp.Tools.Hosting

**Inheritance:** System.Object

## Syntax

```csharp theme={null}
Microsoft.OData.Mcp.Tools.Hosting.ToolsMcpSessionHolder
```

## Summary

A mutable slot for the one [ODataMcpSession](https://ai.easyaf.dev/odata-mcp/api-reference/Microsoft/OData/Mcp/Core/Catalog/ODataMcpSession.md) a Tools host serves, registered before the host
is built and filled once `$metadata` has been fetched and parsed.

## Remarks

The session cannot be registered directly because building it requires the very
[IHttpClientFactory](https://learn.microsoft.com/dotnet/api/system.net.http.ihttpclientfactory) the host owns: the metadata GET runs through the
authenticating `"OData"` client, which only exists after `Build()`, and a service collection is
frozen from that moment on. This holder is what lets one host serve both sides of that ordering.

## Examples

```csharp theme={null}
builder.Services.AddSingleton&lt;ToolsMcpSessionHolder&gt;();
builder.Services.AddMcpServer().WithODataCatalogHandlers(sp =&gt;
{
    var session = sp.GetRequiredService&lt;ToolsMcpSessionHolder&gt;().Session;
    ArgumentNullException.ThrowIfNull(session);

    return session;
});
```

## Constructors

### &#x20;.ctor

#### Syntax

```csharp theme={null}
public ToolsMcpSessionHolder()
```

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public Object()
```

## Properties

### &#x20;Session

Gets or sets the session the MCP handlers resolve, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) until `$metadata`
has been fetched and parsed.

#### Syntax

```csharp theme={null}
public Microsoft.OData.Mcp.Core.Catalog.ODataMcpSession Session { get; set; }
```

#### Property Value

Type: `Microsoft.OData.Mcp.Core.Catalog.ODataMcpSession?`

## Methods

### &#x20;Equals Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public virtual bool Equals(object obj)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `obj` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;Equals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public static bool Equals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;GetHashCode Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public virtual int GetHashCode()
```

#### Returns

Type: `int`

### &#x20;GetType Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public System.Type GetType()
```

#### Returns

Type: `System.Type`

### &#x20;MemberwiseClone Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
protected internal object MemberwiseClone()
```

#### Returns

Type: `object`

### &#x20;ReferenceEquals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public static bool ReferenceEquals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;ToString Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public virtual string ToString()
```

#### Returns

Type: `string?`


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