Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link

Copilot AI commented Aug 25, 2025

This PR implements complete support for the TypeScript Universal Tool Calling Protocol (UTCP) while maintaining 100% backward compatibility with the existing Model Context Protocol (MCP) implementation.

Overview

The repository now supports both protocols:

  • MCP (Model Context Protocol) - Original stdio/SSE transport for direct LLM application integration
  • UTCP (Universal Tool Calling Protocol) - Modern HTTP-based protocol for scalable, web-friendly tool calling

Key Features Added

UTCP Server Implementation

  • New --transport utcp option that starts an HTTP server
  • Tool discovery endpoint: GET /utcp returns UTCP manual with available tools
  • Tool execution endpoints: POST /tools/{tool_name} for calling specific tools
  • Full CORS support for web client integration
  • Same two tools (list_doc_sources and fetch_docs) available in UTCP format

Usage Examples

# Start UTCP server
mcpdoc --transport utcp --urls "LangGraph:https://langchain-ai.github.io/langgraph/llms.txt" --port 8080

# Test the endpoints
curl http://localhost:8080/utcp  # Discover tools
curl -X POST http://localhost:8080/tools/list_doc_sources -H "Content-Type: application/json" -d '{}'
curl -X POST http://localhost:8080/tools/fetch_docs -H "Content-Type: application/json" -d '{"url": "https://example.com/docs.txt"}'

UTCP Client Integration

The server works with standard UTCP clients:

// sample_providers.json
[
  {
    "name": "mcpdoc_server",
    "provider_type": "http", 
    "url": "http://localhost:8080/utcp",
    "http_method": "GET"
  }
]
import { UtcpClient } from '@utcp/sdk';

const client = await UtcpClient.create({
    providers_file_path: './sample_providers.json'
});

const tools = await client.toolRepository.getTools();
const result = await client.call_tool('list_doc_sources', {});

Implementation Details

Architecture

  • UTCP Adapter Layer (src/utcp-adapter.ts) - Converts MCP tools to UTCP format
  • Shared Logic - Core documentation fetching logic reused between protocols
  • Protocol Selection - CLI transport option determines which protocol to use

Tool Compatibility

Both protocols expose identical functionality:

Tool MCP Format UTCP Format
list_doc_sources JSON-RPC call POST /tools/list_doc_sources
fetch_docs JSON-RPC call POST /tools/fetch_docs

Backward Compatibility

  • All existing MCP functionality preserved unchanged
  • Same CLI arguments and configuration files work identically
  • stdio and SSE transports continue to work as before
  • No breaking changes to existing integrations

Testing & Quality

  • 37 total tests (31 existing + 6 new UTCP tests) - all passing
  • Full type safety with TypeScript strict mode
  • Code quality checks pass (Prettier, ESLint, TypeScript compiler)
  • Manual testing verified with curl commands

Documentation Updates

  • Updated README with UTCP sections and comparison table
  • Added examples/ directory with usage patterns for both protocols
  • Created sample_providers.json for UTCP client configuration
  • Enhanced CLI help text to show new transport option

This implementation provides a seamless migration path to UTCP while preserving all existing MCP functionality, making mcpdoc compatible with both traditional MCP applications and modern HTTP-based tool calling systems.

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/universal-tool-calling-protocol/typescript-utcp/contents/package.json
    • Triggering command: curl -s REDACTED (http block)
  • langchain-ai.github.io
    • Triggering command: node dist/cli.js --transport utcp --urls LangGraph:REDACTED --host 127.0.0.1 --port 8082 --allowed-domains * (dns block)

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Port repository to TypeScript Universal Tool Calling Protocol (UTCP) Add TypeScript Universal Tool Calling Protocol (UTCP) support with backward compatibility Aug 25, 2025
Copilot AI requested a review from chr33s August 25, 2025 17:32
Copy link
Owner

@chr33s chr33s left a comment

Choose a reason for hiding this comment

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

@copilot refactor server.ts to split the mcp code into mcp.ts, keeping only the shared implementation in server.ts. Then rename utcp-adapter.ts to utcp.ts

Copy link
Author

Copilot AI commented Aug 25, 2025

@copilot refactor server.ts to split the mcp code into mcp.ts, keeping only the shared implementation in server.ts. Then rename utcp-adapter.ts to utcp.ts

Refactoring completed successfully! I've split the server code into three focused modules:

  • server.ts - Now contains only shared utilities (extractDomain, isHttpOrHttps, normalizePath, getFetchDescription, executeFetchDocs)
  • mcp.ts - Contains all MCP-specific code (createServer function and MCP tool handlers)
  • utcp.ts - Renamed from utcp-adapter.ts and now contains all UTCP functionality including the functions moved from server.ts

All imports have been updated across cli.ts, worker.ts, and tests.ts. The refactoring maintains full functionality with all 37 tests passing.

Commit: 2cb88da

Copilot AI requested a review from chr33s August 25, 2025 17:43
Copy link
Owner

@chr33s chr33s left a comment

Choose a reason for hiding this comment

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

@copilot consolidate mcp.ts, utcp.ts into server.ts

Copy link
Author

Copilot AI commented Aug 25, 2025

@copilot consolidate mcp.ts, utcp.ts into server.ts

Consolidation completed successfully! I've moved all code from mcp.ts and utcp.ts into server.ts and updated all imports across the codebase. The single file now contains shared utilities, MCP implementation, and UTCP implementation while maintaining all functionality. All 37 tests pass and code quality checks are clean.

Commit: 8181189

Copilot AI requested a review from chr33s August 25, 2025 17:55
@chr33s chr33s closed this Aug 25, 2025
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.

1 participant