Application service as a tool
Expose a C# service through a named MCP tool with a clear input contract.
Keep the operation in an application service and describe how clients call it through the MCP adapter. This example measures text without requiring a model or external API.
Create the host and tool
Install Runiq.AI.Mcp and use this complete Program.cs in an ASP.NET Core project:
The explicit text_length name gives clients a stable identifier. "Hello Runiq" returns 11; an empty string returns 0. UTF-16 length does not count visible characters for every language or emoji.
Design the contract
| Part | Responsibility |
|---|---|
| Name | Identify one callable operation. |
| Description | Explain what the operation returns. |
| Parameters | Describe the required input. |
| Service | Execute business rules, validation, and data access. |
This adapter lives in the entry assembly so default discovery can find it. The same service can also be called from a controller or a Runiq agent tool, with its own exposure rules.
Continue with Studio testing.