ValiScore MCP Server

Model Context Protocol server for AI assistant integration with Bittensor validator analysis

MCP v1.0 8 Tools 3 Resources Real-time Data

Overview

The ValiScore MCP Server provides AI assistants with direct access to Bittensor validator analysis and scoring capabilities. It implements the Model Context Protocol (MCP) standard, enabling seamless integration with any MCP-compatible client.

8
Available Tools
3
Resource Types
3
Network Support

Key Features

  • Real-time Analysis: Live Bittensor subnet analysis with blockchain data
  • Scoring Tools: BLEU, ROUGE, and Shapley value calculations
  • Multi-network Support: Connect to finney, test, or local networks
  • Resource Discovery: Queryable subnet and validator information
  • Standardized Interface: MCP v1.0 compliant server

Installation

From Source

git clone https://github.com/sonoran-softworks/valiscore.git
cd valiscore
pip install -e .

Verify Installation

# Check if MCP server is available
valiscore-cli mcp-server --help

# Show MCP configuration
valiscore-cli mcp-config-show

Quick Start

Start MCP Server

# Start server with default settings
valiscore-cli mcp-server

# Start with specific network
valiscore-cli mcp-server --network finney

# Start with custom host and port
valiscore-cli mcp-server --host localhost --port 8000 --network finney --verbose

Python Client Example

import asyncio
from mcp import ClientSession, StdioServerParameters

async def main():
    async with ClientSession(
        StdioServerParameters(
            command="valiscore-cli",
            args=["mcp-server"]
        )
    ) as session:
        
        # List available tools
        tools = await session.list_tools()
        print(f"Available tools: {[tool.name for tool in tools.tools]}")
        
        # Analyze a subnet
        result = await session.call_tool(
            "analyze_subnet",
            {"subnet_id": 1, "network": "finney"}
        )
        print(f"Analysis result: {result.content[0].text}")

asyncio.run(main())

Available Tools

analyze_subnet

Analyze a Bittensor subnet with comprehensive validator and performance data.

analyze_subnet(subnet_id: int, network: str = "finney") -> str

Parameters

Parameter Type Required Description
subnet_id int Yes Bittensor subnet ID to analyze
network str No Network to connect to (finney, test, local)

Returns

JSON string containing comprehensive subnet analysis

Example

result = await session.call_tool("analyze_subnet", {
    "subnet_id": 1,
    "network": "finney"
})
print(result.content[0].text)

compare_subnets

Compare multiple Bittensor subnets side-by-side.

compare_subnets(subnet_ids: List[int], network: str = "finney") -> str

Parameters

Parameter Type Required Description
subnet_ids List[int] Yes List of subnet IDs to compare
network str No Network to connect to

Example

result = await session.call_tool("compare_subnets", {
    "subnet_ids": [1, 2, 3],
    "network": "finney"
})

score_responses

Score multiple responses using BLEU, ROUGE, and weighted metrics.

score_responses(reference: str, responses: List[str], weights: Dict = None) -> str

Parameters

Parameter Type Required Description
reference str Yes Reference text to compare against
responses List[str] Yes List of candidate responses to score
weights Dict No Custom weights for metrics

Example

result = await session.call_tool("score_responses", {
    "reference": "The answer is 42",
    "responses": ["The answer is 42", "It's 42", "42 is the answer"],
    "weights": {"bleu": 0.4, "rouge1": 0.3, "rouge2": 0.2, "rougeL": 0.1}
})

calculate_shapley

Calculate Shapley values for fair contribution distribution.

calculate_shapley(contributions: List[float]) -> str

Example

result = await session.call_tool("calculate_shapley", {
    "contributions": [0.8, 0.6, 0.9]
})

monitor_subnet

Real-time monitoring of subnet activity and performance.

monitor_subnet(subnet_id: int, duration: int = 300, interval: int = 30, network: str = "finney") -> str

Example

result = await session.call_tool("monitor_subnet", {
    "subnet_id": 1,
    "duration": 300,  # 5 minutes
    "interval": 30,   # 30 seconds
    "network": "finney"
})

export_analysis

Export analysis results to various formats.

export_analysis(subnet_id: int, format: str = "json", network: str = "finney") -> str

Example

result = await session.call_tool("export_analysis", {
    "subnet_id": 1,
    "format": "json",
    "network": "finney"
})

Available Resources

MCP resources provide queryable access to Bittensor data and analysis results.

Subnet Resources

subnet://{network}/{subnet_id}

Access subnet information, validator data, and performance metrics.

Validator Resources

validator://{network}/{subnet_id}/{validator_uid}

Detailed information about specific validators.

Analysis Resources

analysis://{network}/{analysis_id}

Stored analysis results and reports.

Example

# List available resources
resources = await session.list_resources()
print(f"Available resources: {[r.uri for r in resources.resources]}")

# Read a specific resource
content = await session.read_resource("subnet://finney/1")
print(content.text)

Configuration

Environment Variables

Variable Default Description
VALISCORE_MCP_HOST localhost MCP server host address
VALISCORE_MCP_PORT 8000 MCP server port
VALISCORE_DEFAULT_NETWORK finney Default Bittensor network
VALISCORE_CONNECTION_TIMEOUT 30 Connection timeout in seconds
VALISCORE_MAX_CONCURRENT 10 Maximum concurrent connections
VALISCORE_LOG_LEVEL INFO Logging level

Configuration File

# config.yaml
mcp_server:
  host: localhost
  port: 8000
  network: finney
  timeout: 30
  max_concurrent: 10
  log_level: INFO

bittensor:
  default_network: finney
  connection_timeout: 30
  retry_attempts: 3

scoring:
  default_weights:
    bleu: 0.4
    rouge1: 0.3
    rouge2: 0.2
    rougeL: 0.1

Client Integration

JavaScript/TypeScript Client

import { ClientSession, StdioServerParameters } from '@modelcontextprotocol/sdk/client/index.js';

async function main() {
    const session = new ClientSession(
        new StdioServerParameters({
            command: 'valiscore-cli',
            args: ['mcp-server']
        })
    );
    
    await session.initialize();
    
    try {
        // Analyze a subnet
        const result = await session.callTool('analyze_subnet', {
            subnet_id: 1,
            network: 'finney'
        });
        console.log('Analysis result:', result.content[0].text);
        
    } finally {
        await session.close();
    }
}

main().catch(console.error);

Rust Client

use mcp::client::{ClientSession, StdioServerParameters};

#[tokio::main]
async fn main() -> Result<(), Box> {
    let session = ClientSession::new(
        StdioServerParameters::new("valiscore-cli", vec!["mcp-server"])
    ).await?;
    
    // Analyze a subnet
    let result = session.call_tool("analyze_subnet", serde_json::json!({
        "subnet_id": 1,
        "network": "finney"
    })).await?;
    
    println!("Analysis result: {}", result.content[0].text);
    
    Ok(())
}

Advanced Examples

Complete Analysis Workflow

import asyncio
from mcp import ClientSession, StdioServerParameters

async def complete_workflow():
    async with ClientSession(
        StdioServerParameters(
            command="valiscore-cli",
            args=["mcp-server", "--network", "finney"]
        )
    ) as session:
        
        # 1. Analyze subnet
        analysis = await session.call_tool("analyze_subnet", {
            "subnet_id": 1
        })
        print("Subnet Analysis:", analysis.content[0].text)
        
        # 2. Compare multiple subnets
        comparison = await session.call_tool("compare_subnets", {
            "subnet_ids": [1, 2, 3]
        })
        print("Subnet Comparison:", comparison.content[0].text)
        
        # 3. Score some responses
        scores = await session.call_tool("score_responses", {
            "reference": "The answer is 42",
            "responses": ["The answer is 42", "It's 42", "42 is the answer"]
        })
        print("Response Scores:", scores.content[0].text)
        
        # 4. Calculate Shapley values
        shapley = await session.call_tool("calculate_shapley", {
            "contributions": [0.8, 0.6, 0.9]
        })
        print("Shapley Values:", shapley.content[0].text)
        
        # 5. Export results
        export = await session.call_tool("export_analysis", {
            "subnet_id": 1,
            "format": "json"
        })
        print("Export Result:", export.content[0].text)

asyncio.run(complete_workflow())

Troubleshooting

Common Issues

Connection Issues

If you can't connect to the MCP server:

  • Check if ValiScore is properly installed
  • Verify the server is running with valiscore-cli mcp-server --help
  • Check network connectivity and firewall settings

Tool Not Found

If a tool is not available:

  • List available tools with session.list_tools()
  • Check tool parameter requirements
  • Verify network connectivity to Bittensor

Performance Issues

For slow response times:

  • Check Bittensor network status
  • Reduce concurrent requests
  • Use caching for repeated queries

Debug Mode

# Start server in debug mode
valiscore-cli mcp-server --verbose --log-level DEBUG

# Check server logs
tail -f valiscore_mcp.log