C# MCP Service Generator. This project shows an example of how to structure an Aspire project to contain a Remote MCP Server which passes through calls to an API backend server. In the world of agents, many existing services will want to expose Remote MCP endpoints so that agents can interact with their APIs.
- .NET 9.0 SDK
- Visual Studio 2022 (17.9+) with the Aspire workload, or
- Aspire workload installed via
dotnet workload install aspire - Node.js v22 or higher.
# From the solution root directory
dotnet build# From the soultion root directory
dotnet run --project .\MCPServiceGenerator.AppHostThis will regenerate the OpenAPI and REST client libraries.
npx tsp compile TypeSpecWhen you run the application, the Aspire AppHost will:
- Start the Aspire Dashboard - Web-based monitoring interface
- Launch MCPServiceGenerator.ApiService - The API backend
- Launch MCPServiceGenerator.MCPService - The MCP Server backend
- Configure service discovery - Enables communication between services
The console output will display URLs for:
- Aspire Dashboard (typically
https://localhost:15888) - API service endpoints
- MCP service endpoints
SwaggerUI is available at the /swagger route.
MCPServiceGenerator.AppHost- Aspire orchestration hostMCPServiceGenerator.ApiService- Web API backendMCPServiceGenerator.ServiceDefaults- Shared configuration and extensionsTypeSpec- REST API Specification
You can test the REST server using SwaggerUI which is available at the
/swagger route.
You can test the MCP Servers using MCP Inspector Enter the MCP Service Endpoint to connect.
npx @modelcontextprotocol/inspector