Content
# NOC.McpServer
An MCP (Model Context Protocol) server that exposes [NiceOneCode](https://www.niceonecode.com)'s JSON → C# class converter as a tool AI assistants can call directly — no more pasting JSON into a web form.
Built with the official [ModelContextProtocol C# SDK](https://github.com/modelcontextprotocol/csharp-sdk), running over stdio transport.
## What it does
Exposes a single tool, `json_to_c_sharp`, which takes a JSON sample and returns the equivalent C# class definitions, generated by NiceOneCode's converter.
Authentication is handled transparently: the server logs in to your NiceOneCode account on first use, caches the JWT, and automatically re-authenticates if it expires.
## Prerequisites
- [.NET 9 SDK](https://dotnet.microsoft.com/download)
- A NiceOneCode account (userid + password)
## Creating an Account
If you don't already have a NiceOneCode account, you can register one via API:
```bash
curl -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
-d '{
"UserName": "your-username",
"Password": "your-password",
"Email": "your-email@example.com",
"GenderID": 1
}' \
'https://www.niceonecode.com/api/nc-register'
```
| Field | Description |
|---|---|
| `UserName` | Desired username |
| `Password` | Desired password — use this as `NOC_PASSWORD` |
| `Email` | A valid email address |
| `GenderID` | `1` = Male, `2` = Female |
**Important:** the response body is a plain string, not a JSON object — for example:
```json
"your-userid"
```
Use this returned value as `NOC_USERID` (not necessarily assumed to always match the `UserName` you submitted — always use the value the API actually returns, rather than the value you sent).
## Setup
1. Clone the repo:
```bash
git clone https://github.com/nice-one-code/NOC.McpServer.git
cd NOC.McpServer
```
2. Build:
```bash
dotnet build
```
3. Set your credentials as environment variables (see [Configuration](#configuration) below) — either in your shell or in your MCP client's config, whichever you're using.
## Configuration
The server reads two required environment variables:
| Variable | Description |
|---|---|
| `NOC_USERID` | Your NiceOneCode userid |
| `NOC_PASSWORD` | Your NiceOneCode password |
Never commit real credentials. Set them via your MCP client's config (see below) or your local shell environment.
## Connecting to an MCP client
Build first so a compiled DLL exists:
```bash
dotnet build
```
Then point your client at `bin/Debug/net9.0/NOC.McpServer.dll`. Use forward slashes in the path even on Windows.
### Claude Desktop
Edit `claude_desktop_config.json` (Windows: `%APPDATA%\Claude\claude_desktop_config.json`, macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`):
```json
{
"mcpServers": {
"niceonecode": {
"command": "dotnet",
"args": ["/absolute/path/to/NOC.McpServer/bin/Debug/net9.0/NOC.McpServer.dll"],
"env": {
"NOC_USERID": "your-userid",
"NOC_PASSWORD": "your-password"
}
}
}
}
```
Fully quit and reopen Claude Desktop after editing.
### Claude Code
```bash
claude mcp add-json niceonecode '{"command":"dotnet","args":["/absolute/path/to/NOC.McpServer/bin/Debug/net9.0/NOC.McpServer.dll"],"env":{"NOC_USERID":"your-username","NOC_PASSWORD":"your-password"}}'
```
Verify with `claude mcp list`.
### Codex
```bash
codex mcp add niceonecode --env NOC_USERID=your-userid --env NOC_PASSWORD=your-password -- dotnet /absolute/path/to/NOC.McpServer/bin/Debug/net9.0/NOC.McpServer.dll
```
Verify inside a session with `/mcp`.
## Testing locally with the MCP Inspector
```bash
npx @modelcontextprotocol/inspector dotnet bin/Debug/net9.0/NOC.McpServer.dll
```
This opens a browser UI where you can invoke `json_to_c_sharp` manually and inspect the raw request/response. Set your credentials under the Inspector's Environment Variables panel before connecting.
## Project structure