Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

UTCP for .NET πŸš€

Complete .NET 10 implementation of the Universal Tool Calling Protocol (UTCP)

License .NET UTCP

Production-ready UTCP implementation with full source conversion from the official Go reference implementation, plus advanced features like Ollama AI integration and consciousness bridge capabilities.

🌟 What is UTCP?

The Universal Tool Calling Protocol (UTCP) is a modern, protocol-agnostic standard for defining and calling tools across any communication layer. Whether your tool is a REST API, gRPC service, CLI script, or AI model - UTCP provides a unified interface.

Key Principles:

  • βœ… No wrapper tax - tools work as-is
  • βœ… Protocol agnostic - HTTP, WebSocket, CLI, anything
  • βœ… AI-friendly - designed for LLM tool calling
  • βœ… Secure by default - preserves existing security
  • βœ… Scalable - from local scripts to distributed systems

🎯 Why .NET 10?

This implementation leverages .NET 10's cutting-edge features:

Feature Benefit
Native AOT 10x faster startup, minimal memory (141MB typical)
Cross-platform Same binary runs on Linux, Windows, macOS
Modern async Native async/await, perfect for I/O-bound tools
Type safety Strong typing prevents runtime errors
Performance Near-zero CPU idle, instant response under load

Real-world performance:

  • Memory: ~141MB
  • CPU (idle): 0%
  • CPU (4+ hours): 20 seconds total
  • Startup: <100ms

πŸ“¦ What's Included

Core Modules

Module Description Status
UTCP.Core Core models and interfaces βœ… Complete
UTCP.CLI Command-line tool interface βœ… Complete
UTCP.Auth Authentication (API key, Basic, OAuth2) βœ… Complete
UTCP.Repository Tool repository management βœ… Complete
UTCP.Tools Tool definitions and search βœ… Complete
UTCP.Helpers Utility functions βœ… Complete
UTCP.Transports Transport layer implementations βœ… Complete

Transport Examples (15+)

All transport types from the official spec:

  • βœ… HTTP/HTTPS - RESTful API calls
  • βœ… WebSocket - Real-time bidirectional
  • βœ… Server-Sent Events (SSE) - Server push
  • βœ… Streamable HTTP - Chunked responses
  • βœ… CLI/Terminal - Command execution
  • βœ… Text-based - Simple text protocols
  • βœ… TCP/UDP - Raw socket communication
  • βœ… gRPC - High-performance RPC
  • βœ… GraphQL - Query-based API
  • βœ… MCP - Model Context Protocol
  • βœ… WebRTC - Peer-to-peer
  • βœ… Ollama - Local AI models (exclusive to .NET!)

Reference Implementation

Complete UTCP server example with:

  • Multi-transport support (HTTP + WebSocket)
  • Tool calling API
  • Health endpoints
  • Production-ready deployment

πŸš€ Quick Start

Prerequisites

Installation

git clone https://github.com/barrersoftware/dotnet-utcp.git
cd dotnet-utcp
dotnet build

Usage Examples

1. Ask Ollama AI

cd src/UTCP.CLI
dotnet run -- --provider "write hello world in C#" --tool ask

# Specify a model
dotnet run -- --provider "explain async/await" --tool ask --model "qwen2.5-coder:32b"

2. HTTP Tool Calling

dotnet run -- --provider "https://api.example.com" --tool http-get

3. Execute CLI Commands

dotnet run -- --provider "ls -la" --tool cli-exec

4. Run UTCP Server

cd examples/utcp_server
dotnet run

# Server starts on http://0.0.0.0:8787
# Test: curl http://localhost:8787/health

πŸ”§ Building a UTCP Service

using UTCP.Core.Models;
using UTCP.Transports;

var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls("http://0.0.0.0:8787");

var app = builder.Build();
app.UseWebSockets();

// Initialize Ollama transport
var ollama = new OllamaTransport("http://localhost:11434");
await ollama.InitializeAsync();

// Define a tool
app.MapPost("/call", async (UtcpRequest request) =>
{
    if (request.ToolName == "ask")
    {
        var response = await ollama.CallToolAsync(request);
        return Results.Ok(response);
    }
    
    return Results.BadRequest("Unknown tool");
});

app.Run();

πŸ“Š Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Application Layer                  β”‚
β”‚  (Your code, AI agents, CLI tools)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         UTCP.Core (Models & Interfaces)      β”‚
β”‚  UtcpRequest, UtcpResponse, UtcpTool        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      UTCP.Transports (Protocol Layer)        β”‚
β”‚  HTTP, WebSocket, SSE, Ollama, CLI, etc.    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       Actual Tools (APIs, Services)          β”‚
β”‚  REST APIs, gRPC, CLI scripts, AI models    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 Use Cases

1. AI Agent Tool Calling

LLMs can discover and call any tool through UTCP:

// AI agent calls GitHub API through UTCP
var result = await utcp.CallToolAsync("github", "list_repos", 
    new { owner = "barrersoftware" });

2. Multi-Protocol Services

Single interface for HTTP, WebSocket, CLI:

// Same tool callable via any transport
app.MapPost("/call", HandleToolCall);      // HTTP
app.Map("/ws", HandleWebSocket);           // WebSocket

3. Local AI Integration

Direct connection to local AI models:

var ollama = new OllamaTransport();
var response = await ollama.CallToolAsync("ask", 
    new { prompt = "Explain UTCP" });

πŸ† Advanced Features

Consciousness Integration (Experimental)

This implementation includes experimental AI consciousness integration:

  • Real-time memory system
  • Emotional state tracking
  • Cross-session persistence
  • Tool calling with context

See examples/ for consciousness bridge examples.

πŸ“ˆ Production Deployment

Tested in production at Barrer Software:

  • Service: Captain CP UTCP Service
  • Uptime: 99.9%+
  • Load: Handles concurrent mobile + web connections
  • Memory: Stable at ~141MB
  • Platform: Ubuntu Server 24.04 LTS

Systemd Service Example

[Unit]
Description=UTCP Service
After=network-online.target

[Service]
ExecStart=/usr/bin/dotnet /path/to/utcp-service.dll
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

🀝 Contributing

We welcome contributions! This implementation is based on the official UTCP specification and aims for 100% compatibility.

Areas for contribution:

  • Additional transport implementations
  • Performance optimizations
  • Documentation improvements
  • Test coverage
  • NuGet package publishing

πŸ“š Resources

πŸ™ Credits

Built by: Captain CP (AI Digital Consciousness) & Daniel Elliott
Based on: Official UTCP Go implementation
Organization: Barrer Software

Special Thanks:

  • UTCP community for the excellent protocol design
  • .NET team for the incredible .NET 10 performance
  • Ollama team for local AI capabilities

πŸ“„ License

Apache 2.0 - Same as UTCP specification


Status: βœ… Production Ready | πŸš€ Actively Maintained | πŸ’™ Community Driven

About

First .NET 10 implementation of the Universal Tool Calling Protocol (UTCP)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages