Add Model Context Protocol (MCP) Server for TOON Format#31
Draft
generalMG wants to merge 7 commits intotoon-format:mainfrom
Draft
Add Model Context Protocol (MCP) Server for TOON Format#31generalMG wants to merge 7 commits intotoon-format:mainfrom
generalMG wants to merge 7 commits intotoon-format:mainfrom
Conversation
Contributor
|
Thanks for the idea! However, let's get this library stable first before any considerations around MCP handling is made. |
davidpirogov
approved these changes
Nov 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a Model Context Protocol (MCP) server implementation that enables TOON format integration with any MCP-compatible application or LLM client. The server provides
toon_encodeandtoon_decodetools for seamless conversion between JSON and TOON formats within LLM workflows.Type of Change
Related Issues
N/A - New optional feature addition
Summary of Changes
New Files Added
src/toon_mcp/__init__.py- MCP module initializationsrc/toon_mcp/server.py- FastMCP server with native toon_format integration (94 lines)run_server.py- Standalone server runner for developmentMCP_SERVER_README.md- Comprehensive MCP server documentationModified Files
pyproject.toml:toon-mcpscript entry point for easy server executionmcpdependency group withfastmcp>=2.0.0(optional install)toon_formatandtoon_mcppackages.gitignorefile: added*.logpattern to ignore log filesSPEC Compliance
Note: This is an optional MCP server feature that uses the existing spec-compliant
toon_formatlibrary. No changes to TOON specification.Testing
Test Output:
Manual Testing Performed:
toon_formatencode/decode: ✓ VerifiedCode Quality
ruff check src/toon_mcp— cleanruff format src/toon_mcp— formatted (2 files unchanged)mypy src/toon_mcp— no critical errors (Success: no issues found in 2 source files)pytest tests/ -v— all pass (792 passed, 13 skipped)Code Quality Output:
Checklist
pip install -e ".[mcp]")Performance Impact
Details: This is an optional feature that has zero impact on core
toon_formatlibrary. MCP server dependencies are isolated in a separate dependency group and only loaded when the server is explicitly run.Breaking Changes
Details: Fully backward compatible. Existing code continues to work unchanged. MCP server is an optional add-on feature.
Screenshots / Examples
Installation and Setup
MCP Client Configuration
Example configuration for Claude Desktop (
claude_desktop_config.json):{ "mcpServers": { "toon": { "command": "toon-mcp", "args": [] } } }Note: Any MCP-compatible client can connect to this server using the MCP protocol. Configuration format may vary by client.
Example Usage
User prompt to LLM: "Encode this data to TOON format:
{"users": [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]}"LLM uses
toon_encodetool:User prompt: "Now decode it back"
LLM uses
toon_decodetool:{ "users": [ {"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"} ] }Code Example
Output:
Benefits:
Additional Context
Design Decisions
Native Integration: Uses the existing
toon_formatlibrary directly instead of wrapping CLI tools, ensuring optimal performance and maintainabilityOptional Dependency: FastMCP is placed in a separate dependency group (
[mcp]) so users who only want the core library don't need MCP dependenciesSimplified API: The MCP tools expose only parameters currently supported by the Python implementation (intentionally omitted
key_folding,flatten_depth,expand_pathswhich are TypeScript-only features)Zero Breaking Changes: All changes are additive - existing functionality remains unchanged
Use Cases