Skip to content

feat: add built-in MCP server (kuronuri serve --mcp)#1

Open
sgtao wants to merge 8 commits into
sincekmori:mainfrom
sgtao:feature/add-mcp-server
Open

feat: add built-in MCP server (kuronuri serve --mcp)#1
sgtao wants to merge 8 commits into
sincekmori:mainfrom
sgtao:feature/add-mcp-server

Conversation

@sgtao
Copy link
Copy Markdown

@sgtao sgtao commented May 17, 2026

Summary

Integrates a Model Context Protocol (MCP) server
directly into kuronuri, so users can expose PII masking as AI tools without a separate
package.

Changes

New: kuronuri serve --mcp

Starts an MCP server over stdio transport, registering two tools for MCP clients such as
Claude Code and Claude Desktop:

Tool Description
mask_text Mask PII in text with configurable language, strategy, and tags
list_ner_tags Return a Markdown table of NER tags for a given language

Claude Code registration example:

{
  "mcpServers": {
    "kuronuri": {
      "command": "kuronuri",
      "args": ["serve", "--mcp"]
    }
  }
}

Dependency

mcp[cli]>=1.0.0 is added as a regular dependency, so pip install kuronuri gives
you the MCP functionality without any extra steps.

Backward compatibility

The existing kuronuri <INPUT> interface is fully preserved via a default-command
routing group (_DefaultMaskGroup). No changes are required for existing users.

Checklist

  • mise run fix passes (ruff + ty)
  • mise run test-all passes on Python 3.10–3.14 with 100% coverage
  • All code and comments written in English
  • License: Apache-2.0 (unchanged)
  • pyproject.toml: version bumped 0.2.00.3.0

Modified files

  • src/kuronuri/_mcp.py — new MCP server module (FastMCP-based)
  • src/kuronuri/_cli.py — added serve subcommand and _DefaultMaskGroup for backward-compatible routing
  • pyproject.toml — added mcp[cli] dependency, bumped version to 0.3.0
  • tests/test_mcp.py — new tests for MCP tools
  • tests/test_cli.py — added TestServeCommand; existing tests updated for new routing
  • README.md / CHANGELOG.md — updated docs

(On May 18th, Appended Follows)

Testing MCP in Development

To verify the MCP server works before installing from PyPI, register it directly from
your local branch using Claude Code:

setup and check connect

# Move to any working directory outside the repo
cd /path/to/your/workspace

# Register the local build as an MCP server
claude mcp add kuronuri -- uv run --directory /path/to/kuronuri kuronuri serve --mcp

# Confirm the server is connected
claude mcp list
# Expected output:
# kuronuri: uv run --directory ... - ✓ Connected

Usage

Then launch Claude Code and send a masking request:

claude

Example prompt (Japanese):

「山田太郎 は yamada.taro@example.com のメールアドレスを持ってます」を黒塗りにして下さい

Expected behavior:

  • Claude Code calls the mask_text MCP tool automatically
  • The masked result is returned inline:
████ は ███████████@███████████ のメールアドレスを持ってます

@codecov-commenter
Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

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.

2 participants