The Intermud3 Gateway provides a JSON-RPC 2.0 API over WebSocket and TCP for MUD servers to integrate with the global Intermud-3 network. This document describes the available methods, their parameters, and expected responses.
Current Status: Phase 3 Complete (2025-08-20) - Full implementation with 78% test coverage, 1200+ tests.
- WebSocket:
ws://localhost:8080/ws - TCP Socket:
localhost:8081 - Protocol: JSON-RPC 2.0
- Encoding: UTF-8
{
"jsonrpc": "2.0",
"method": "authenticate",
"params": {
"api_key": "your-api-key-here"
},
"id": 1
}Response:
{
"jsonrpc": "2.0",
"result": {
"status": "authenticated",
"mud_name": "YourMUD",
"session_id": "unique-session-id"
},
"id": 1
}Send a private message to a user on another MUD.
Request:
{
"jsonrpc": "2.0",
"method": "send_tell",
"params": {
"from_user": "sender",
"to_mud": "TargetMUD",
"to_user": "recipient",
"message": "Hello there!"
},
"id": 2
}Response:
{
"jsonrpc": "2.0",
"result": {
"status": "sent",
"timestamp": 1642345678
},
"id": 2
}Send an emote to a user on another MUD.
Request:
{
"jsonrpc": "2.0",
"method": "send_emoteto",
"params": {
"from_user": "sender",
"to_mud": "TargetMUD",
"to_user": "recipient",
"emote": "waves cheerfully"
},
"id": 3
}Get list of available I3 channels.
Request:
{
"jsonrpc": "2.0",
"method": "channel_list",
"id": 4
}Response:
{
"jsonrpc": "2.0",
"result": {
"channels": [
{
"name": "chat",
"type": "public",
"owner": "RouterMUD"
},
{
"name": "code",
"type": "public",
"owner": "DevMUD"
}
]
},
"id": 4
}Join an I3 channel.
Request:
{
"jsonrpc": "2.0",
"method": "channel_join",
"params": {
"channel": "chat",
"user": "player"
},
"id": 5
}Leave an I3 channel.
Request:
{
"jsonrpc": "2.0",
"method": "channel_leave",
"params": {
"channel": "chat",
"user": "player"
},
"id": 6
}Send a message to a channel.
Request:
{
"jsonrpc": "2.0",
"method": "channel_send",
"params": {
"channel": "chat",
"user": "player",
"message": "Hello everyone!"
},
"id": 7
}Get list of users on a specific MUD.
Request:
{
"jsonrpc": "2.0",
"method": "who",
"params": {
"target_mud": "SomeMUD"
},
"id": 8
}Response:
{
"jsonrpc": "2.0",
"result": {
"mud": "SomeMUD",
"users": [
{"name": "player1", "idle": 0, "level": 50},
{"name": "player2", "idle": 300, "level": 25}
]
},
"id": 8
}Get detailed information about a user.
Request:
{
"jsonrpc": "2.0",
"method": "finger",
"params": {
"target_mud": "SomeMUD",
"target_user": "player"
},
"id": 9
}Response:
{
"jsonrpc": "2.0",
"result": {
"user": "player",
"mud": "SomeMUD",
"title": "the Adventurer",
"real_name": "John",
"email": "player@example.com",
"last_on": 1642345678,
"idle": 0,
"level": 50
},
"id": 9
}Find a user across the entire I3 network.
Request:
{
"jsonrpc": "2.0",
"method": "locate",
"params": {
"user": "player"
},
"id": 10
}Response:
{
"jsonrpc": "2.0",
"result": {
"found": true,
"mud": "SomeMUD",
"user": "player",
"idle": 0,
"status": "active"
},
"id": 10
}Get list of all MUDs on the I3 network.
Request:
{
"jsonrpc": "2.0",
"method": "mudlist",
"id": 11
}Response:
{
"jsonrpc": "2.0",
"result": {
"muds": [
{
"name": "MUD1",
"type": "LP",
"status": "up",
"address": "mud1.example.com",
"port": 4000,
"players": 25
},
{
"name": "MUD2",
"type": "Circle",
"status": "up",
"address": "mud2.example.com",
"port": 5000,
"players": 10
}
]
},
"id": 11
}The gateway sends events to the MUD when messages or data are received from the I3 network.
Received when another user sends a tell to a player on your MUD.
{
"jsonrpc": "2.0",
"method": "event",
"params": {
"type": "tell_received",
"data": {
"from_user": "sender",
"from_mud": "RemoteMUD",
"to_user": "recipient",
"message": "Hello!",
"timestamp": 1642345678
}
}
}Received when a message is sent to a joined channel.
{
"jsonrpc": "2.0",
"method": "event",
"params": {
"type": "channel_message",
"data": {
"channel": "chat",
"user": "speaker",
"mud": "RemoteMUD",
"message": "Hello channel!",
"timestamp": 1642345678
}
}
}Response to a who request.
{
"jsonrpc": "2.0",
"method": "event",
"params": {
"type": "who_reply",
"data": {
"request_id": 8,
"mud": "QueriedMUD",
"users": [...]
}
}
}Response to a finger request.
{
"jsonrpc": "2.0",
"method": "event",
"params": {
"type": "finger_reply",
"data": {
"request_id": 9,
"user_info": {...}
}
}
}Response to a locate request.
{
"jsonrpc": "2.0",
"method": "event",
"params": {
"type": "locate_reply",
"data": {
"request_id": 10,
"found": true,
"location": {...}
}
}
}The gateway returns standard JSON-RPC error responses:
{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "Invalid params",
"data": "Missing required parameter: to_user"
},
"id": 2
}-32700: Parse error-32600: Invalid request-32601: Method not found-32602: Invalid params-32603: Internal error1000: Authentication required1001: Not authorized1002: Target not found1003: Service unavailable1004: Rate limit exceeded
Get gateway connection status.
Request:
{
"jsonrpc": "2.0",
"method": "status",
"id": 100
}Response:
{
"jsonrpc": "2.0",
"result": {
"connected": true,
"router": "*i3",
"uptime": 3600,
"messages_sent": 1234,
"messages_received": 5678,
"channels_joined": ["chat", "code"],
"version": "0.2.0"
},
"id": 100
}Test gateway connectivity.
Request:
{
"jsonrpc": "2.0",
"method": "ping",
"id": 101
}Response:
{
"jsonrpc": "2.0",
"result": "pong",
"id": 101
}The gateway implements rate limiting to prevent abuse:
- Tells: 10 per minute per user
- Channel messages: 20 per minute per channel
- Who requests: 5 per minute
- Finger requests: 10 per minute
- Locate requests: 5 per minute
Exceeding these limits will result in error code 1004.
import json
import socket
class I3GatewayClient:
def __init__(self, host='localhost', port=8081): # TCP port
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.connect((host, port))
self.request_id = 0
def send_request(self, method, params=None):
self.request_id += 1
request = {
"jsonrpc": "2.0",
"method": method,
"id": self.request_id
}
if params:
request["params"] = params
message = json.dumps(request) + '\n'
self.socket.send(message.encode('utf-8'))
response = self.socket.recv(4096).decode('utf-8')
return json.loads(response)
def send_tell(self, from_user, to_mud, to_user, message):
return self.send_request("send_tell", {
"from_user": from_user,
"to_mud": to_mud,
"to_user": to_user,
"message": message
})
# Usage
client = I3GatewayClient()
result = client.send_tell("player", "OtherMUD", "friend", "Hello!")
print(result)- Persistent Connections: Maintain a persistent connection to the gateway rather than connecting for each request
- Event Handling: Implement async event handling for incoming messages
- Error Recovery: Implement automatic reconnection on connection loss
- Rate Limiting: Implement client-side rate limiting to avoid hitting server limits
- Logging: Log all I3 communication for debugging and audit purposes
- Security: Use the shared secret authentication and validate all incoming data
- 0.2.0: Phase 2 Complete - Core services implemented (tell, channel, who, finger, locate)
- Full test coverage for all services (60% overall)
- Circuit breakers and retry mechanisms
- Connection pooling and health checks
- Performance benchmarks and stress testing
- 0.3.0: Phase 3 Complete (2025-08-20) - Gateway API Protocol
- Full JSON-RPC 2.0 implementation
- WebSocket (port 8080) and TCP (port 8081) support
- Client libraries (Python, JavaScript/Node.js with TypeScript)
- Comprehensive documentation
- Authentication and state management
- Event distribution system
- 78% test coverage with 1200+ tests
- 0.4.0: OOB services and advanced features (planned)