Skip to content

Features/mcp server - #56

Merged
jjrdk merged 29 commits into
masterfrom
features/mcp-server
May 24, 2026
Merged

Features/mcp server#56
jjrdk merged 29 commits into
masterfrom
features/mcp-server

Conversation

@jjrdk

@jjrdk jjrdk commented May 24, 2026

Copy link
Copy Markdown
Owner

Add MCP server project

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new opencertserver.mcp server project intended to expose CA functionality via MCP/JSON-RPC over stdio, alongside a new Reqnroll-based test suite for MCP behaviors. The PR also centralizes NuGet package version management and removes the old shared.proj imports across many projects.

Changes:

  • Introduce src/opencertserver.mcp (server host, stdio transport, MCP core DTOs/options, tool registration helper).
  • Add tests/opencertserver.mcp.tests with Reqnroll features/steps to validate MCP tool registration and tool behaviors.
  • Migrate multiple projects to Central Package Management (Directory.Packages.props) and simplify csproj package references / remove shared.proj.

Reviewed changes

Copilot reviewed 74 out of 80 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
tests/opencertserver.tpm.tests/opencertserver.tpm.tests.csproj Switches to central package versions and normalizes csproj formatting.
tests/opencertserver.mcp.tests/TestSharedState.cs Adds shared state container for Reqnroll step definitions (used across MCP test scenarios).
tests/opencertserver.mcp.tests/Support/McpServerFixture.cs Introduces test fixture to host an in-memory CA + MCP server for scenario execution.
tests/opencertserver.mcp.tests/StepDefinitions/McpServerToolsSteps.cs Step definitions for tool registration/listing checks.
tests/opencertserver.mcp.tests/StepDefinitions/McpServerRevocationSteps.cs Step definitions for CRL/OCSP/revocation-status tool scenarios.
tests/opencertserver.mcp.tests/StepDefinitions/McpServerMetadataSteps.cs Step definitions for get_server_metadata validation.
tests/opencertserver.mcp.tests/StepDefinitions/McpServerCertificateQuerySteps.cs Step definitions for list/search/get/get-ca-certs tool scenarios.
tests/opencertserver.mcp.tests/StepDefinitions/McpServerCertificateOperationsSteps.cs Step definitions for sign/revoke tool scenarios and inventory assertions.
tests/opencertserver.mcp.tests/StepDefinitions/CommonToolsSteps.cs Shared steps for asserting success/failure + common error-message checks.
tests/opencertserver.mcp.tests/opencertserver.mcp.tests.csproj Adds the MCP test project and references to MCP + CA projects.
tests/opencertserver.mcp.tests/Features/McpServerTools.feature.cs Generated Reqnroll test runner for tool-registration feature.
tests/opencertserver.mcp.tests/Features/McpServerTools.feature Feature spec for tool registration expectations.
tests/opencertserver.mcp.tests/Features/McpServerRevocation.feature Feature spec for CRL/OCSP/revocation-status expectations.
tests/opencertserver.mcp.tests/Features/McpServerMetadata.feature.cs Generated Reqnroll test runner for metadata feature.
tests/opencertserver.mcp.tests/Features/McpServerMetadata.feature Feature spec for server metadata output.
tests/opencertserver.mcp.tests/Features/McpServerCertificateQuery.feature.cs Generated Reqnroll test runner for certificate query feature.
tests/opencertserver.mcp.tests/Features/McpServerCertificateQuery.feature Feature spec for list/search/get/get-ca-certs behaviors.
tests/opencertserver.mcp.tests/Features/McpServerCertificateOperations.feature.cs Generated Reqnroll test runner for sign/revoke feature.
tests/opencertserver.mcp.tests/Features/McpServerCertificateOperations.feature Feature spec for sign/revoke tool behaviors and inventory effects.
tests/opencertserver.lambda.tests/opencertserver.lambda.tests.csproj Removes shared.proj import and moves to central package versions.
tests/opencertserver.est.server.tests/opencertserver.est.server.tests.csproj Removes shared.proj import; switches test dependencies to central versions/TestHost.
tests/opencertserver.cli.tests/opencertserver.cli.tests.csproj Removes explicit TF/package versions; relies on repo-level build props + central packages.
tests/opencertserver.certserver.tests/opencertserver.certserver.tests.csproj Removes shared.proj import; migrates package refs to central versions.
tests/opencertserver.ca.tests/opencertserver.ca.tests.csproj Removes shared.proj import; migrates package refs to central versions.
tests/opencertserver.acme.aspnetclient.tests/opencertserver.acme.aspnetclient.tests.csproj Removes shared.proj import; migrates package refs to central versions.
tests/opencertserver.acme.abstractions.tests/opencertserver.acme.abstractions.tests.csproj Removes shared.proj import; migrates package refs to central versions.
tests/CertesSlim.tests/Pkcs/CertificationRequestBuilderTests.cs Adjusts nullability annotations in assertions.
tests/CertesSlim.tests/IAcmeContextExtensionsTests.cs Cleans usings and updates nullability annotations for test data.
tests/CertesSlim.tests/Helper.v2.cs Updates nullability annotation for DirectoryMeta test helper.
tests/CertesSlim.tests/Helper.cs Fixes nullability warnings with null-forgiving and MemberExpression assumptions.
tests/CertesSlim.tests/CertesSlim.tests.csproj Migrates package refs to central versions and normalizes formatting.
tests/CertesSlim.tests/Acme/Resource/DirectoryTests.cs Cleans usings and updates nullability for test construction.
tests/CertesSlim.tests/Acme/Resource/AccountTests.cs Adds null-forgiving where deserialize can return null.
tests/CertesSlim.tests/Acme/EntityContextTests.cs Adjusts nullability for AcmeHttpResponse test setup.
tests/CertesSlim.tests/Acme/AcmeHttpClientTests.cs Cleans usings + adjusts nullability in mocked responses.
tests/CertesSlim.tests/Acme/AcmeContextTests.cs Cleans usings + adjusts nullability in mocked responses.
src/opencertserver.tss.net/opencertserver.tss.net.csproj Removes shared.proj import (keeps custom warning/trim settings).
src/opencertserver.tpm/TssTpmKeyProvider.cs Minor refactors (var usage) in simulator initialization/signing logic.
src/opencertserver.tpm/TpmCaProfileFactory.cs Minor refactors (var usage) in self-signed CA certificate creation.
src/opencertserver.tpm/TpmCaCertificateStore.cs Minor refactor (var usage) when iterating stale certificates.
src/opencertserver.tpm/opencertserver.tpm.csproj Removes shared.proj import.
src/opencertserver.mcp/Transport/McpStdioTransport.cs Adds stdio JSON-RPC transport implementation for MCP.
src/opencertserver.mcp/RegisterTools.cs Adds extension to register all MCP tools on the server.
src/opencertserver.mcp/README.md Adds minimal README for MCP project.
src/opencertserver.mcp/Program.cs Adds MCP server entrypoint that hosts stdio transport.
src/opencertserver.mcp/opencertserver.mcp.csproj Adds MCP server executable project and references CA projects.
src/opencertserver.mcp/McpToolResult.cs Defines tool invocation result wrapper (success/error).
src/opencertserver.mcp/McpToolDefinition.cs Defines tool metadata and handler delegate.
src/opencertserver.mcp/McpToolContext.cs Provides tool handler context + DI scope access.
src/opencertserver.mcp/McpServerOptions.cs Adds MCP server configuration options.
src/opencertserver.mcp/McpServerExtensions.cs Adds DI helper to register MCP server.
src/opencertserver.mcp/McpServer.cs Adds core MCP server implementation (tool registry, invoke, stdio start/stop).
src/opencertserver.mcp/McpInstruments.cs Adds OpenTelemetry metrics/tracing helpers for tool invocations.
src/opencertserver.mcp/McpErrorCode.cs Defines MCP/JSON-RPC + CA-specific error codes.
src/opencertserver.mcp/McpCertificateStatus.cs Defines status enum for revocation checks.
src/opencertserver.mcp/McpCertificateSearchResult.cs Adds paginated search result DTO for MCP.
src/opencertserver.mcp/McpCertificateItem.cs Adds certificate DTO returned by MCP tools.
src/opencertserver.mcp/GlobalUsings.cs Adds global usings for MCP project.
src/opencertserver.lambda/opencertserver.lambda.csproj Removes shared.proj import; migrates package ref to central versions.
src/opencertserver.est.server/opencertserver.est.server.csproj Removes shared.proj import; migrates package refs to central versions.
src/opencertserver.est.client/opencertserver.est.client.csproj Removes shared.proj import.
src/opencertserver.cli/opencertserver.cli.csproj Removes explicit TF/package version and migrates to central package versioning.
src/opencertserver.certserver/opencertserver.certserver.csproj Removes shared.proj import.
src/opencertserver.ca/opencertserver.ca.csproj Removes shared.proj import; migrates package refs to central versions.
src/opencertserver.ca/CaProfileSet.cs Adds GetProfiles() to enumerate all CA profiles asynchronously.
src/opencertserver.ca.utils/opencertserver.ca.utils.csproj Removes shared.proj import.
src/opencertserver.ca.utils/Ca/IStoreCaProfiles.cs Extends interface to support enumerating all CA profiles.
src/opencertserver.ca.utils/Ca/CertificateSearchResult.cs Adds a CA-level paginated certificate search result DTO.
src/opencertserver.ca.server/opencertserver.ca.server.csproj Removes shared.proj import; migrates package refs to central versions.
src/opencertserver.ca.server/Extensions.cs Rewrites extension declarations into standard C# extension methods and updates registrations.
src/opencertserver.acme.server/opencertserver.acme.server.csproj Removes shared.proj import; migrates package refs to central versions.
src/opencertserver.acme.aspnetclient/opencertserver.acme.aspnetclient.csproj Removes shared.proj import.
src/opencertserver.acme.abstractions/opencertserver.acme.abstractions.csproj Removes shared.proj import.
src/CertesSlim/CertesSlim.csproj Removes shared.proj import; migrates package refs to central versions.
opencertserver.slnx Adds MCP server + MCP tests projects; removes shared.proj solution entry.
opencertserver.sln.DotSettings Updates ReSharper nullable-warning suppression setting.
Directory.Packages.props Introduces central package version management and pins common dependency versions.
Directory.Build.props Minor formatting adjustment (license expression indentation).
Files not reviewed (5)
  • tests/opencertserver.mcp.tests/Features/McpServerCertificateOperations.feature.cs: Language not supported
  • tests/opencertserver.mcp.tests/Features/McpServerCertificateQuery.feature.cs: Language not supported
  • tests/opencertserver.mcp.tests/Features/McpServerMetadata.feature.cs: Language not supported
  • tests/opencertserver.mcp.tests/Features/McpServerRevocation.feature.cs: Language not supported
  • tests/opencertserver.mcp.tests/Features/McpServerTools.feature.cs: Language not supported
Comments suppressed due to low confidence (1)

tests/opencertserver.mcp.tests/StepDefinitions/McpServerToolsSteps.cs:107

  • ThenTheToolDescriptionContains is a no-op, so any scenario using this step would not actually validate the tool’s description content. Either implement the assertion (by selecting a tool definition and checking Description contains the keyword) or remove the step to avoid false-positive tests.

Comment thread src/opencertserver.mcp/Transport/McpStdioTransport.cs
Comment thread src/opencertserver.mcp/Transport/McpStdioTransport.cs Outdated
Comment thread src/opencertserver.mcp/Transport/McpStdioTransport.cs Outdated
Comment thread src/opencertserver.mcp/Transport/McpStdioTransport.cs Outdated
Comment thread src/opencertserver.mcp/Program.cs
Comment thread tests/opencertserver.mcp.tests/TestSharedState.cs
Comment thread tests/opencertserver.mcp.tests/StepDefinitions/McpServerRevocationSteps.cs Outdated
Comment thread tests/opencertserver.mcp.tests/StepDefinitions/CommonToolsSteps.cs
Comment thread src/opencertserver.mcp/McpServer.cs Outdated

Copilot AI commented May 24, 2026

Copy link
Copy Markdown
Contributor

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/jjrdk/opencertserver/pulls/56/comments
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI commented May 24, 2026

Copy link
Copy Markdown
Contributor

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/jjrdk/opencertserver/pulls/comments/3294286706
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of jjrdk May 24, 2026 12:30

Copilot AI commented May 24, 2026

Copy link
Copy Markdown
Contributor

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/jjrdk/opencertserver/pulls/comments/3294286765
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 14 commits May 24, 2026 18:02
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jjrdk/opencertserver/sessions/f0f56ac7-fbb1-47fa-8d82-34013e54de37

Co-authored-by: jjrdk <149390+jjrdk@users.noreply.github.com>
Co-authored-by: jjrdk <149390+jjrdk@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jjrdk/opencertserver/sessions/a87cdba1-2d4b-42a5-89af-b74ff463471f

Co-authored-by: jjrdk <149390+jjrdk@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jjrdk/opencertserver/sessions/9a4ba216-f8d1-4163-a828-95d8a4da8a9a

Co-authored-by: jjrdk <149390+jjrdk@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jjrdk/opencertserver/sessions/557b7cc7-62fe-4bcf-a83e-3b0bf00a9f32

Co-authored-by: jjrdk <149390+jjrdk@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jjrdk/opencertserver/sessions/14364963-0972-4ab1-82d2-3cad3305f1d5

Co-authored-by: jjrdk <149390+jjrdk@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jjrdk/opencertserver/sessions/ad3229b5-b185-4651-91f9-37ffdf641efa

Co-authored-by: jjrdk <149390+jjrdk@users.noreply.github.com>
Copilot AI and others added 2 commits May 24, 2026 16:18
- Add CA service registration to Program.cs
- Fix McpServer logger initialization with ILoggerFactory
- Fix JsonDocument disposal in McpStdioTransport (3 locations)
- Fix HandleToolsCall to properly handle JsonElement parameters
- Remove dead code in error data handling
- Add ParameterHelper utility for safe parameter extraction
- Fix all tool parameter parsing to handle JsonElement
- Fix issuer field in ListCertificatesTool and SearchCertificatesTool
- Update SearchCertificatesTool description to reflect current behavior
- Fix GetCertificateTool to return actual revocation status
- Fix GetCaCertificatesTool serial number format
- Fix SignCertificateTool to support PEM CSR and use DateTimeOffset
- Add hex validation to GetRevocationStatusTool and CheckOcspStatusTool
- Update test fixture to pass loggerFactory

Agent-Logs-Url: https://github.com/jjrdk/opencertserver/sessions/2c86380d-f0cb-4e7b-9f68-d6a4398aebe6

Co-authored-by: jjrdk <149390+jjrdk@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jjrdk/opencertserver/sessions/2c86380d-f0cb-4e7b-9f68-d6a4398aebe6

Co-authored-by: jjrdk <149390+jjrdk@users.noreply.github.com>
jjrdk added 3 commits May 24, 2026 18:50
- Fix includeFullChain boolean parsing in GetCaCertificatesTool to use
  ParameterHelper.GetBoolean() for JsonElement compatibility
- Implement actual filtering in SearchCertificatesTool instead of
  ignoring filter parameters:
  - subjectCN/subjectContains: substring match on DN
  - issuerContains: substring match on issuer DN
  - serialNumber/thumbprint: substring match
  - notBeforeAfter/before, notAfterAfter/before: date range filtering
  - status: Good/Revoked via IsRevoked check
  - keyAlgorithms: acknowledged as not yet supported (requires loading cert)
- Update tool schema descriptions to reflect filtering is now active
…initions

The root cause of 8 test failures was that Reqnroll's Table constructor
takes column headers only — Copilot's generated code passed data values
as headers (e.g. `new Table({"serialNumber", "ZZZZ"})`) instead of
using AddRow(), resulting in zero data rows and empty parameter dicts
flowing to every tool handler.

Fixes applied:
- McpServerParameterHandling.feature: add Key/Value header rows to all
  parameter tables so Reqnroll generates proper Table + AddRow() code
- ParameterHandlingSteps.cs: fix array placeholder to quote serial numbers
  (e.g. ["{serial}"] instead of [{serial}]) for valid JSON deserialization;
  add missing Given/Then step definitions for Background and error-message
  checks
- TestSharedState.cs: add lost IssuedSerialNumber property (deleted in
  Copilot commit)
- opencertserver.mcp.tests.csproj: suppress IL trim/AOT warnings not
  applicable to test projects
- McpServerFixture.cs, CommonToolsSteps.cs: clean up whitespace
- Add Issuer property to CertificateItemInfo and propagate to CertificateItem
- Update ListCertificatesTool and SearchCertificatesTool to use real issuer from store
- Add CollectionBehavior to disable test parallelization (static shared state)
- Clean up diagnostic code and fix Reqnroll table serialization issues
@jjrdk

jjrdk commented May 24, 2026

Copy link
Copy Markdown
Owner Author

Copilot PR Review Comments - Resolution Summary

All inline review comments from copilot-pull-request-reviewer have been addressed:

Transport Layer (McpStdioTransport.cs)

  • ErrorResult property name: Resolved in 0da990f[JsonPropertyName("error")] added
  • SendCapabilities single quotes: Resolved in 8bc2f8b — valid JSON + clones JsonElement before disposing
  • async without await: Resolved in d779c6f — removed async from non-awaiting methods
  • HandleToolsCall throws on missing name: Resolved in 00c6c23 — uses TryGetProperty, returns -32602
  • JsonDocument not disposed: Resolved — using var doc = JsonDocument.Parse(raw) on every path
  • HandleToolsList JsonDocument leak: Resolved — using var result for Parse output
  • dataDoc dead code: Removed with explanatory comment

Entry Point (Program.cs)

  • CancelKeyPress timing: Registered before StartAsync; StartAsync runs on background Task
  • Missing CA service registration: AddInMemoryCertificateStore() + AddSelfSignedCertificateAuthority() added

MCP Server (McpServer.cs)

  • EnableTelemetry not honored: Instrumentation calls guarded by if (_options.EnableTelemetry)
  • ILogger cast fails: Uses ILoggerFactory.CreateLogger()

Tools (b8e149b)

  • Missing tool implementations: All 10 tools now have implementations
  • JsonElement param parsing: ParameterHelper.GetInt32() / GetBoolean() / GetStringArray()
  • Issuer = DistinguishedName: Now uses info.Issuer ?? info.DistinguishedName with new Issuer property
  • Search filters ignored: All filter fields implemented with client-side filtering
  • keyAlgorithms array: ParameterHelper.GetStringArray() for proper JsonElement array handling
  • IsRevoked always false: Now looks up inventory by serial and sets IsRevoked correctly
  • Little-endian serial hex: Uses GetSerialNumberString() for big-endian hex

Tests (f290d49, 4d87844, 080deae)

  • IssueAsync no-op: Removed
  • Static mutable state + parallel tests: CollectionBehavior.DisableTestParallelization added
  • CRL includePem no-op: ThenCrlBytesMustBeBase64 verifies Base64 decoding
  • ThenFirstCheckMustMatchSerial: Now asserts serial matches
  • ThenToolHasValidSchema: Validates InputSchema non-empty and valid JSON

Build: Clean (0 warnings, 0 errors)
Tests: 59/59 passing

@gitguardian

gitguardian Bot commented May 24, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
33137670 Triggered RSA Private Key fa0bd4e tests/CertesSlim.tests/Keys.cs View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@jjrdk
jjrdk merged commit 8b3b601 into master May 24, 2026
6 checks passed
jjrdk added a commit that referenced this pull request May 24, 2026
- Add Issuer property to CertificateItemInfo and propagate to CertificateItem
- Update ListCertificatesTool and SearchCertificatesTool to use real issuer from store
- Add CollectionBehavior to disable test parallelization (static shared state)
- Clean up diagnostic code and fix Reqnroll table serialization issues
@jjrdk
jjrdk deleted the features/mcp-server branch May 24, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants