A Model Context Protocol (MCP) server that enables Claude AI to interact with .NET Core APIs through CRUD operations and Swagger/OpenAPI integration.
- HTTP Methods Support (GET, POST, PUT, DELETE, PATCH)
- Swagger/OpenAPI Integration
- Multi-environment Configuration (local, development, beta, production)
- Automatic Endpoint Discovery
- Model/Schema Tracking
- Dynamic Query Parameters
- Authentication Support
- Configurable Timeouts & Headers
Install the package:
npm install -g dotnet-api-mcpConfigure Claude Desktop:
-
Open your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Add the MCP server configuration:
{
"mcpServers": {
"dotnet-api": {
"command": "npx",
"args": ["-y", "dotnet-api-mcp"],
"env": {}
}
}
}- Restart Claude Desktop
Step 1.1: Install the package in your project:
npm install dotnet-api-mcpStep 1.2: Add MCP server to Claude Code:
claude mcp add dotnet-api-mcp dotnet-api-mcpStep 1.3: Restart VSCode
Create a config.json file in your project root directory (where package.json is located):
Option 1 - Copy from example:
cp node_modules/dotnet-api-mcp/config.example.json config.jsonOption 2 - Create manually:
Create config.json with the following structure:
{
"environments": {
"local": {
"baseUrl": "https://localhost:7000/api",
"swaggerUrl": "https://localhost:7000/swagger/v1/swagger.json",
"auth": {
"email": "your-email@example.com",
"password": "your-password"
}
}
},
"activeEnvironment": "local",
"timeout": 30000,
"headers": {
"Content-Type": "application/json",
"Accept": "application/json"
}
}Update config.json with your actual API information:
-
baseUrl: Your API base URL
"baseUrl": "https://localhost:7000/api"
⚠️ Warning: If missing, API requests will fail with "No base URL configured" -
swaggerUrl: Your Swagger/OpenAPI documentation URL
"swaggerUrl": "https://localhost:7000/swagger/v1/swagger.json"
⚠️ Warning: If missing, Swagger tools won't work
-
auth (if your API requires authentication):
"auth": { "email": "your-email@example.com", "password": "your-password" }
ℹ️ Info: You can omit this section if your API doesn't require authentication
-
timeout (default: 30000ms):
"timeout": 30000
ℹ️ Info: Increase if your API responses are slow
-
headers (custom HTTP headers):
"headers": { "Content-Type": "application/json", "Accept": "application/json" }
ℹ️ Info: Add any custom headers your API requires
You can configure multiple environments for different stages:
{
"environments": {
"local": {
"baseUrl": "https://localhost:7000/api",
"swaggerUrl": "https://localhost:7000/swagger/v1/swagger.json"
},
"development": {
"baseUrl": "https://dev-api.example.com/api",
"swaggerUrl": "https://dev-api.example.com/swagger/v1/swagger.json"
},
"beta": {
"baseUrl": "https://beta-api.example.com/api",
"swaggerUrl": "https://beta-api.example.com/swagger/v1/swagger.json"
},
"production": {
"baseUrl": "https://api.example.com/api",
"swaggerUrl": "https://api.example.com/swagger/v1/swagger.json"
}
},
"activeEnvironment": "local"
}activeEnvironment to specify which environment to use.
Ask Claude to test the connection:
"Fetch the Swagger documentation from my API"
If successful, you'll see the API endpoints. If not, check these common issues:
Common Issues:
| Error | Solution |
|---|---|
| "Cannot find config.json" | Ensure config.json is in your project root |
| "No base URL configured" | Add baseUrl to your environment config |
| "Connection refused" | Check if your API is running |
| "Swagger not found" | Verify swaggerUrl is correct and accessible |
| "Authentication failed" | Check your auth credentials |
{
"environments": {
"local": {
"baseUrl": "https://localhost:7000/api",
"swaggerUrl": "https://localhost:7000/swagger/v1/swagger.json",
"auth": {
"email": "user@example.com",
"password": "password123"
}
}
},
"activeEnvironment": "local",
"timeout": 30000,
"headers": {
"Content-Type": "application/json",
"Accept": "application/json",
"X-Custom-Header": "custom-value"
}
}To switch between environments, update activeEnvironment:
{
"activeEnvironment": "production"
}Make GET requests to your API
// List all users
api_get("/users")
// Get user by ID with params
api_get("/users/123", { include: "profile" })Make POST requests to create resources
api_post("/users", {
"name": "John Doe",
"email": "john@example.com"
})Make PUT requests to update resources
api_put("/users/123", {
"name": "Jane Doe",
"email": "jane@example.com"
})Make DELETE requests
api_delete("/users/123")Make PATCH requests for partial updates
api_patch("/users/123", {
"email": "newemail@example.com"
})Fetch Swagger/OpenAPI documentation
swagger_fetch({ environment: "beta" })List all API endpoints
// List all endpoints
swagger_list_endpoints()
// Filter by tag
swagger_list_endpoints({ tag: "User" })
// Filter by method
swagger_list_endpoints({ method: "POST" })Get detailed information about a specific endpoint
swagger_get_endpoint({
path: "/api/users/{id}",
method: "GET"
})Get model/schema definition from Swagger
swagger_get_schema({ schemaName: "UserDto" })You: "Fetch the Swagger documentation for my API"
Claude: [Uses swagger_fetch tool]
You: "List all users from the beta environment"
Claude: [Uses api_get with /users endpoint]
You: "Create a new product with name 'Laptop' and price 999"
Claude: [Uses api_post with /products endpoint]
import { spawn } from 'child_process';
const mcp = spawn('node', ['node_modules/dotnet-api-mcp/src/index.js']);
// MCP server is now running and can receive requestsgit clone https://github.com/sametbrr/dotnet-api-mcp.git
cd dotnet-api-mcp
npm install
npm startnpm run dev- Verify your API URL in
config.json - Check if API accepts CORS requests
- Ensure SSL certificates are valid
- Update auth credentials in
config.json - Check if API requires token-based auth
- Verify
swaggerUrlis accessible - Ensure Swagger JSON endpoint is exposed
- Node.js >= 18.0.0
- .NET Core API with Swagger/OpenAPI support
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details
Samet Birer