Context for AI coding agents (and humans) working in this repository. Canonical prose lives in README.md and CONTRIBUTING.md; this file is the high-signal summary.
Note:
GEMINI.mdis a different thing. It is the end-user context for the hosted MCP server, referenced bygemini-extension.json. Do not put repo build or contributor instructions there.
A Model Context Protocol server (C# / .NET 10) that exposes the InvoiceXML API to AI agents: create, validate, render, extract, embed, and convert e-invoices across Factur-X, ZUGFeRD, XRechnung, UBL / CII, and Peppol BIS Billing 3.0.
One codebase, two deployment shapes, selected at startup by Mcp:AuthMode:
ApiKey (self-hosted, single API key) or OAuth (hosted, OAuth 2.1 + DCR
against invoicexml.com). The repo is platform-independent: it knows nothing
about where or how it is hosted.
dotnet build # whole solution (warnings are errors)
dotnet test # all tests (xUnit)
dotnet test tests/InvoiceXml.Mcp.Core.Tests/InvoiceXml.Mcp.Core.Tests.csproj
dotnet run --project src/InvoiceXml.Mcp.Host # run the host locallyRequires a .NET 10 SDK (global.json floor is 10.0.100, rolls forward to the
latest 10.0.x). To run, supply an API key first, kept outside the repo:
dotnet user-secrets --project src/InvoiceXml.Mcp.Host set "Mcp:ApiKey:Value" "<key>".
Local endpoints: GET / welcome page, POST / MCP endpoint, GET /health.
InvoiceXml.Mcp.Core --ProjectReference--> InvoiceXml.Mcp.Host
(SDK: client + tools) (the deployable ASP.NET Core app)
- Core is a transport- and auth-agnostic SDK:
IInvoiceXmlClient+HttpInvoiceXmlClient, the DTOs/enums, and the[McpServerTool]classes. It consumes anHttpClientfromIHttpClientFactoryand never sees credentials. - Host reads
Mcp:AuthModeand attaches the matching auth as anHttpClientDelegatingHandlerviaAddHostAuth(...). That handler seam is the whole reason one codebase serves both modes.
- Core knows nothing about authentication. Never add an API key or token to
InvoiceXmlClientOptionsor the Core client. Auth is host-side only. - A new tool = one method on
IInvoiceXmlClient+ one[McpServerTool]class. No edits toProgram.csor DI wiring (tools are auto-discovered from the assembly). - A new auth mode = one arm in
AuthExtensions.AddHostAuth+ one folder undersrc/InvoiceXml.Mcp.Host/Auth/<Mode>/. No edits to Core. - Folder = namespace. In every
InvoiceXml.*library,I*contracts go inInterfaces/, concretes inServices/. - No secrets in any committed file, ever.
appsettings.Development.jsonis gitignored; never put a real key inappsettings.json, docs, or tests. - Tests are required for new functionality.
create_invoice, validate_xml_invoice, validate_pdf_invoice,
render_invoice, extract_invoice, embed_invoice, convert_invoice.
They live in src/InvoiceXml.Mcp.Core/Tools/. File inputs prefer a public
https:// URL (*Url params) over inline base64. Tools never throw on bad input:
they return a structured failure (ToolResults.ForFailure or a valid=false
ValidationResult) so the agent can self-correct.
Keys (appsettings.json or environment variables). For env vars, each : becomes
__ (double underscore); root keys have no separator.
| Config key | Env var | Notes |
|---|---|---|
Mcp:AuthMode |
Mcp__AuthMode |
ApiKey or OAuth |
Mcp:ApiKey:Value |
Mcp__ApiKey__Value or INVOICEXML_API_KEY |
ApiKey mode only |
Mcp:OAuth:AuthorizationServer |
Mcp__OAuth__AuthorizationServer |
OAuth mode |
McpUri |
McpUri |
root-level; required in OAuth mode |
InvoiceXml:BaseUrl |
InvoiceXml__BaseUrl |
API base URL |
- Central Package Management: add or bump NuGet versions in
Directory.Packages.props, never in individual.csprojfiles. .editorconfigis authoritative.TreatWarningsAsErrorsis on; fix analyzer warnings, do not suppress them. File-scoped namespaces; expression-bodied members where clearer.- Shared build settings live in
Directory.Build.props(targetnet10.0, nullable enabled, implicit usings). - Keep prose plain: no em dashes (use commas, parentheses, or colons).
- New tool?
src/InvoiceXml.Mcp.Core/Tools/andInterfaces/IInvoiceXmlClient.cs. - Auth / deployment?
src/InvoiceXml.Mcp.Host/Auth/andConfiguration/. - Result shaping for tools?
src/InvoiceXml.Mcp.Core/Tools/ToolResults.cs,ArtifactTools.cs,ToolFailure.cs. - Tests mirror the source tree under
tests/.