OpenRouterMcp Documentation

Welcome to the comprehensive API reference for the OpenRouterMcp SDK and Server.

OpenRouterMcp.Sdk.ConversationManager

Manages conversation history and storage.

Methods

SetStoragePath

void SetStoragePath(String projectPath)

Sets the root directory for storing conversation files.

SaveConversationAsync

Task SaveConversationAsync(String name, Object messages)

Saves a conversation to disk.

GetConversationContextAsync

Task<String> GetConversationContextAsync(String name)

Retrieves the full context of a saved conversation.

LoadConversationAsync

Task<T> LoadConversationAsync(String name)

Loads a conversation object from disk.

ListConversations

String[] ListConversations()

Lists all saved conversations in the current storage path.

OpenRouterMcp.Sdk.FileManager

Provides robust file system operations.

Methods

ReadFileAsync

Task<String> ReadFileAsync(String path)

Reads text content from a file.

WriteFileAsync

Task WriteFileAsync(String path, String content)

Writes text content to a file, overwriting if it exists.

ListFiles

String[] ListFiles(String directory, String searchPattern, Boolean recursive)

Lists files in a directory matching a pattern.

OpenRouterMcp.Sdk.IModelManager

Interface for AI Model interactions.

Properties

  • ActiveModel: The currently selected model ID.
  • AppTitle: The application title sent in headers.
  • AppReferer: The referrer URL sent in headers.

Methods

SwitchModel

void SwitchModel(String modelId)

Changes the active AI model.

ResolveContextAsync

Task<String> ResolveContextAsync(String prompt, CancellationToken cancellationToken)

Resolves context based on the prompt.

PromptAsync

Task<PromptResult> PromptAsync(String prompt, String modelOverride, Object tools, CancellationToken cancellationToken)

Sends a prompt to the AI model and returns the result.

SearchWebAsync

Task<PromptResult> SearchWebAsync(String query, CancellationToken cancellationToken)

Performs a web search using the configured provider.

PromptStreamAsync

IAsyncEnumerable<String> PromptStreamAsync(String prompt, String modelOverride, CancellationToken cancellationToken)

Streams the response from the AI model.

OpenRouterMcp.Sdk.ProcessManager

Manages background processes.

Methods

StartProcess

Int32 StartProcess(String fileName, String arguments)

Starts a new process and returns its PID.

ReadOutput

String ReadOutput(Int32 pid)

Reads the standard output of a running process.

KillProcess

String KillProcess(Int32 pid)

Terminates a process by its PID.

ListProcesses

String[] ListProcesses()

Lists all tracked processes.

OpenRouterMcp.Sdk.ShellExecutor

Executes shell commands.

Methods

ExecuteCommandAsync

Task<String> ExecuteCommandAsync(String command, String workingDirectory, CancellationToken cancellationToken)

Executes a shell command in the specified directory.


OpenRouterMcp Server

Documentation for the MCP Server implementation.

OpenRouterMcp.Server.AgentTools

Exposed tools for external agents (via MCP).

Methods

request_edit

Task<String> request_edit(String file_path, String description)

Requests an edit to a specific file.

propose_command

String propose_command(String command)

Proposes a command to be executed.

approve_command

Task<String> approve_command()

Approves the last proposed command.

read_file

Task<String> read_file(String file_path)

Reads the content of a file.

list_files

Task<String> list_files(String directory, String pattern)

Lists files in a directory.

create_file

Task<String> create_file(String file_path, String content)

Creates a new file with the specified content.

delete_file

String delete_file(String file_path)

Deletes a file.

switch_model

String switch_model(String model_id)

Switches the model used by the server.

list_conversations

String list_conversations()

Lists available saved conversations.

save_conversation

Task<String> save_conversation(String name, String content)

Saves the current conversation.

search_web

Task<String> search_web(String query)

Performs a web search using the server's tools.

start_process

String start_process(String file_name, String arguments)

Starts a process on the host machine.

read_process_output

String read_process_output(Int32 pid)

Reads output from a tracked process.

kill_process

String kill_process(Int32 pid)

Kills a tracked process.

list_processes

String list_processes()

Lists all active tracked processes.

search_files

Task<String> search_files(String pattern, String directory, String file_pattern)

Searches for content within files.

git_status

Task<String> git_status()

Runs git status in the current repo.

git_diff

Task<String> git_diff()

Runs git diff.

git_log

Task<String> git_log(Int32 count)

Returns the git log.