Class McpService
Manages MCP integration for LM Studio native Track B chat requests. Reads registered connectors from McpConnectorCatalog and builds the ephemeral_mcp / plugin payload for native /api/v1/chat requests.
MCP is opt-in: only active when LMStudioSettings.NativeTrack is enabled and there are connectors in the catalog.
Implements
Inherited Members
Namespace: Glitch9.AIDevKit.LMStudio.Services
Assembly: Glitch9.AIDevKit.Provider.LMStudio.dll
Syntax
public class McpService : CrudServiceBase<LMStudioClient>, ICrudService
Constructors
| Edit this page View SourceMcpService(LMStudioClient)
Declaration
public McpService(LMStudioClient client)
Parameters
| Type | Name | Description |
|---|---|---|
| LMStudioClient | client |
Properties
| Edit this page View SourceSession
Stateful conversation session for native Track B chat. Holds the conversation_id for multi-turn continuations.
Declaration
public NativeConversationSession Session { get; }
Property Value
| Type | Description |
|---|---|
| NativeConversationSession |
Methods
| Edit this page View SourceBuildPayload()
Builds the MCP payload (ephemeral_mcp + plugins) from McpConnectorCatalog entries. Returns (null, null) when the catalog is empty or unavailable. Connectors are forwarded only when the catalog has registered entries and explicit user opt-in.
Declaration
public (LMStudioEphemeralMcp ephemeralMcp, List<LMStudioPlugin> plugins) BuildPayload()
Returns
| Type | Description |
|---|---|
| (LMStudioEphemeralMcp ephemeralMcp, List<LMStudioPlugin> plugins) |
ClearSession()
Clears the active conversation session. The next native chat request will start a fresh conversation.
Declaration
public void ClearSession()
InitializeSession(LMStudioNativeChatResponse)
Records the conversation_id from the server's first native chat response. Call this after the first CreateNativeAsync to enable stateful continuation.
Declaration
public void InitializeSession(LMStudioNativeChatResponse firstResponse)
Parameters
| Type | Name | Description |
|---|---|---|
| LMStudioNativeChatResponse | firstResponse |