# Pub-Sub Topic Router AI Agent Connect

> Deterministic routing engine for hierarchical topic patterns and wildcard subscriptions.

## Overview
- **Category:** infrastructure
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_YypGCTjPI7PKDomfphyCPFniAy7uz6773LlrdLyk/ai-agent-connect
- **Tags:** pubsub, routing, wildcard, qos, hierarchy

## Description

This MCP server provides a deterministic routing engine for managing hierarchical message delivery. It allows AI agents to calculate exact matching subscribers using wildcard patterns like `*` for single levels and `#` for multi-level matching. Use `match_subscribers` to identify targets, `calculate_delivery_impact` to evaluate traffic and QoS guarantees, and `analyze_topic_complexity` to inspect topic depth and expansion potential. It is designed to manage fanout impact and back-pressure in complex agent communication networks.

## Tools

### analyze_topic_complexity
Inspects the structure of a topic to determine routing complexity and expansion potential

### calculate_delivery_impact
Evaluates the resource requirements and guarantees for a single message publication

### match_subscribers
Identifies which specific agents should receive a message published to a specific topic

## Prompt Examples

**Prompt:** 
```
Find all subscribers for the topic 'agents.planner.tasks.high' with these subscriptions: [{'agentId': 'agent_1', 'topicPattern': 'agents.#'}, {'agentId': 'agent_2', 'topicPattern': 'agents.*.tasks.*'}]
```

**Response:** 
```
The matching subscribers are agent_1 and agent_2. The total fanout count is 2.
```

**Prompt:** 
```
Calculate the delivery impact for a 500 byte message on topic 'sensor.temp' with QoS level 1 and matching subscribers: [{'agentId': 'sub_1', 'queueSize': 50, 'isOnline': true}]
```

**Response:** 
```
The delivery guarantee is at least once. Total traffic is 500 bytes. No back-pressure is needed.
```

**Prompt:** 
```
Analyze the complexity of the topic 'a.b.c.d' with patterns ['a.#', 'a.*.c.*']
```

**Response:** 
```
The topic depth is 4. The expansion count for the provided patterns is 2.
```

## Frequently Asked Questions

**How does wildcard matching work?**
The router uses `*` to match exactly one level in a hierarchy and `#` to match all remaining levels.

**What is the maximum topic depth supported?**
The system supports a maximum topic depth of 10 levels.

**How is back-pressure handled?**
If a subscriber's queue exceeds 1000 messages, the `calculate_delivery_impact` tool flags that back-pressure is needed to slow down the publisher.
