ayn

ayn - Agents You Need

A meta-framework for discovering, installing, and integrating reusable AI agents. Acts as the ‘pip + Docker Hub + Postman’ for AI agents.

Core Features:

  1. Search & Discovery: Find agents across GitHub, HuggingFace, awesome lists

  2. Standard Controller Interface: Parametrizable agent controllers with action methods

  3. HTTP/REST Export: FastAPI and LangServe wrappers

  4. MCP Support: Model Context Protocol server integration

  5. Custom Actions: ChatGPT and Claude action generation

Architecture:

  • Search layer: Unified registry across multiple sources

  • Controller protocol: Standard interface for invoking agents

  • Export layer: HTTP/REST service generation

  • MCP layer: Tools, resources, and prompts

  • Actions: OpenAPI specs for ChatGPT/Claude

Example

>>> from ayn import AgentRegistry, BaseAgentController
>>> registry = AgentRegistry()
>>> results = registry.search('data preparation agents')
>>> agent = BaseAgentController.from_metadata(results[0])
>>> result = agent.invoke(input_data)

Functions

export_as_fastapi(controller[, metadata, ...])

Export agent controller as FastAPI service

export_as_langserve(controller[, metadata])

Export agent as LangServe compatible service

controller_to_mcp_server(controller, metadata, *)

Convert an agent controller to MCP server

generate_chatgpt_action(controller, ...)

Generate ChatGPT custom action configuration

generate_claude_mcp_config(mcp_server, ...)

Generate Claude Desktop MCP configuration

create_agent_from_registry(registry, query)

Search registry and create agent controller

export_agent_full_stack(controller, metadata, *)

Export agent with all integrations

Classes

AgentFramework(*values)

Supported agent frameworks

AgentModality(*values)

Agent modalities

AgentMetadata(name, description, framework)

Metadata for an agent

ControllerConfig([model, temperature, ...])

Configuration for agent controllers

AgentSearcher(*args, **kwargs)

Protocol for agent search implementations

GitHubAgentSearcher([github_token])

Search for agents in GitHub repositories

HuggingFaceAgentSearcher([hf_token])

Search for agents on Hugging Face

AwesomeListSearcher()

Parse and search awesome lists for agents

AgentRegistry([searchers, cache_dir])

Unified registry for searching and managing agents

AgentController(*args, **kwargs)

Standard protocol for agent controllers

BaseAgentController(config)

Base class for agent controllers

GenericController(metadata, config)

Generic controller for custom agents

CrewAIController(metadata, config)

Controller for CrewAI agents

LangChainController(metadata, config)

Controller for LangChain agents

AutoGenController(metadata, config)

Controller for AutoGen agents

MCPTool(name, description, input_schema[, ...])

MCP tool definition

MCPResource(uri, name[, mimeType, description])

MCP resource definition

MCPPrompt(name, description[, arguments])

MCP prompt template

MCPServer(name[, version, controller])

MCP Server implementation

class ayn.AgentController(*args, **kwargs)[source]

Bases: Protocol

Standard protocol for agent controllers

Controllers provide a uniform interface for invoking agents regardless of their underlying framework.

Example

>>> class MyController:
...     def __init__(self, config):
...         self.config = config
...     def invoke(self, input_data, **kwargs):
...         return f"Processed: {input_data}"
>>> controller = MyController({'model': 'gpt-4'})
>>> controller.invoke('test')
'Processed: test'
async ainvoke(input_data, **kwargs)[source]

Invoke the agent asynchronously

Return type:

Any

invoke(input_data, **kwargs)[source]

Invoke the agent synchronously

Parameters:
  • input_data (Any) – Input data for the agent

  • **kwargs – Additional parameters

Return type:

Any

Returns:

Agent output

stream(input_data, **kwargs)[source]

Stream agent outputs

Return type:

Iterable[Any]

class ayn.AgentFramework(*values)[source]

Bases: Enum

Supported agent frameworks

class ayn.AgentMetadata(name, description, framework, source='', tags=list(), modality=AgentModality.TEXT, version='0.1.0', author='', license='', dependencies=list(), capabilities=list())[source]

Bases: object

Metadata for an agent

Example

>>> meta = AgentMetadata(
...     name="data-prep-agent",
...     description="Prepares data for visualization",
...     framework=AgentFramework.CREWAI
... )
>>> meta.name
'data-prep-agent'
classmethod from_dict(data)[source]

Create from dictionary

Return type:

AgentMetadata

to_dict()[source]

Convert to dictionary

Example

>>> meta = AgentMetadata(name="test", description="test agent", framework=AgentFramework.CREWAI)
>>> d = meta.to_dict()
>>> d['name']
'test'
Return type:

dict

class ayn.AgentModality(*values)[source]

Bases: Enum

Agent modalities

class ayn.AgentRegistry(searchers=None, cache_dir=None)[source]

Bases: MutableMapping[str, AgentMetadata]

Unified registry for searching and managing agents

Aggregates results from multiple sources and provides a dict-like interface.

Pass searchers=[] for a local-only registry, and a cache_dir to keep the cache out of ~/.ayn/registry.

Example

>>> import tempfile
>>> registry = AgentRegistry(searchers=[], cache_dir=tempfile.mkdtemp())
>>> # Add a local agent
>>> from ayn.core import AgentMetadata, AgentFramework
>>> meta = AgentMetadata(name="test", description="test", framework=AgentFramework.CUSTOM)
>>> registry['test'] = meta
>>> registry['test'].name
'test'
>>> 'test' in registry
True
search(query, *, limit=20, source=None, **filters)[source]

Search across all sources

Parameters:
  • query (str) – Search query

  • limit (int) – Max results

  • source (Optional[str]) – Specific source to search (github, huggingface, awesome)

  • **filters – Additional filters

Return type:

List[AgentMetadata]

Returns:

List of agent metadata

Example

>>> import tempfile
>>> registry = AgentRegistry(searchers=[], cache_dir=tempfile.mkdtemp())
>>> # Add some test data
>>> from ayn.core import AgentMetadata, AgentFramework
>>> registry['agent1'] = AgentMetadata(
...     name="agent1", description="test agent",
...     framework=AgentFramework.CREWAI, tags=['data']
... )
>>> results = registry.search('agent')
>>> len(results) >= 1
True
class ayn.AgentSearcher(*args, **kwargs)[source]

Bases: Protocol

Protocol for agent search implementations

search(query, *, limit=20, **filters)[source]

Search for agents

Parameters:
  • query (str) – Search query string

  • limit (int) – Maximum results to return

  • **filters – Additional filters (framework, tags, etc.)

Return type:

Iterable[AgentMetadata]

Returns:

Iterable of agent metadata

class ayn.AutoGenController(metadata, config)[source]

Bases: GenericController

Controller for AutoGen agents

Not implemented yet: today this behaves exactly like GenericController (it echoes its input) and does not run an AutoGen agent. See AYN_IMPLEMENTATION_ROADMAP.md for details

class ayn.AwesomeListSearcher[source]

Bases: object

Parse and search awesome lists for agents

Example

>>> searcher = AwesomeListSearcher()
>>> results = searcher.search('autogen')
search(query, *, limit=20, **filters)[source]

Search awesome lists

Return type:

Iterable[AgentMetadata]

class ayn.BaseAgentController(config)[source]

Bases: ABC

Base class for agent controllers

Provides common functionality and enforces the controller protocol.

Example

>>> class SimpleController(BaseAgentController):
...     def invoke(self, input_data, **kwargs):
...         return f"Result: {input_data}"
>>> controller = SimpleController(ControllerConfig())
>>> controller.invoke('test')
'Result: test'
async ainvoke(input_data, **kwargs)[source]

Default async implementation wraps synchronous invoke

Return type:

Any

classmethod from_metadata(metadata, config=None)[source]

Factory method to create controller from metadata

Return type:

BaseAgentController

abstractmethod invoke(input_data, **kwargs)[source]

Invoke the agent - must be implemented by subclasses

Return type:

Any

stream(input_data, **kwargs)[source]

Default streaming yields single result

Return type:

Iterable[Any]

class ayn.ControllerConfig(model='gpt-4', temperature=0.7, max_tokens=1000, timeout=60, retry_count=3, api_key=None, additional_params=dict())[source]

Bases: object

Configuration for agent controllers

Example

>>> config = ControllerConfig(
...     model="gpt-4",
...     temperature=0.7,
...     max_tokens=1000
... )
>>> config.model
'gpt-4'
to_dict()[source]

Convert to dictionary

Return type:

dict

class ayn.CrewAIController(metadata, config)[source]

Bases: GenericController

Controller for CrewAI agents

Not implemented yet: today this behaves exactly like GenericController (it echoes its input) and does not run a CrewAI agent. See AYN_IMPLEMENTATION_ROADMAP.md for details

class ayn.GenericController(metadata, config)[source]

Bases: BaseAgentController

Generic controller for custom agents

Example

>>> from ayn.core import AgentMetadata, AgentFramework, ControllerConfig
>>> meta = AgentMetadata(name="test", description="test", framework=AgentFramework.CUSTOM)
>>> controller = GenericController(meta, ControllerConfig())
>>> result = controller.invoke({'input': 'test'})
invoke(input_data, **kwargs)[source]

Generic invoke - subclasses override for specific behavior

Return type:

Any

class ayn.GitHubAgentSearcher(github_token=None)[source]

Bases: object

Search for agents in GitHub repositories

Example

>>> searcher = GitHubAgentSearcher()
>>> results = searcher.search('crewai agent')
search(query, *, limit=20, **filters)[source]

Search GitHub for agent repos (not implemented: raises NotImplementedError)

Return type:

Iterable[AgentMetadata]

class ayn.HuggingFaceAgentSearcher(hf_token=None)[source]

Bases: object

Search for agents on Hugging Face

Uses the Hugging Face MCP tool if available.

Example

>>> searcher = HuggingFaceAgentSearcher()
>>> results = searcher.search('code generation')
search(query, *, limit=20, **filters)[source]

Search Hugging Face for agents

Return type:

Iterable[AgentMetadata]

class ayn.LangChainController(metadata, config)[source]

Bases: GenericController

Controller for LangChain agents

Not implemented yet: today this behaves exactly like GenericController (it echoes its input) and does not run a LangChain agent. See AYN_IMPLEMENTATION_ROADMAP.md for details

class ayn.MCPPrompt(name, description, arguments=list())[source]

Bases: object

MCP prompt template

Example

>>> prompt = MCPPrompt(
...     name="summarize",
...     description="Summarize text",
...     arguments=[{"name": "text", "description": "Text to summarize", "required": True}]
... )
>>> prompt.name
'summarize'
to_dict()[source]

Convert to MCP prompt format

Return type:

dict

class ayn.MCPResource(uri, name, mimeType='text/plain', description='')[source]

Bases: object

MCP resource definition

Example

>>> resource = MCPResource(
...     uri="file:///data.csv",
...     name="Dataset",
...     mimeType="text/csv"
... )
>>> resource.name
'Dataset'
to_dict()[source]

Convert to MCP resource format

Return type:

dict

class ayn.MCPServer(name, version='1.0.0', controller=None)[source]

Bases: object

MCP Server implementation

Exposes agent capabilities via Model Context Protocol.

Example

>>> server = MCPServer(name="test-server")
>>> tool = MCPTool(
...     name="greet",
...     description="Greet user",
...     input_schema={"type": "object", "properties": {}}
... )
>>> server.add_tool(tool)
>>> len(server.tools)
1
add_prompt(prompt)[source]

Add a prompt to the server

add_resource(resource)[source]

Add a resource to the server

add_tool(tool)[source]

Add a tool to the server

Example

>>> server = MCPServer("test")
>>> tool = MCPTool("test", "test tool", {})
>>> server.add_tool(tool)
>>> server.tools[0].name
'test'
handle_call_tool(tool_name, arguments)[source]

Handle tools/call request

Return type:

dict

handle_list_prompts()[source]

Handle prompts/list request

Return type:

dict

handle_list_resources()[source]

Handle resources/list request

Return type:

dict

handle_list_tools()[source]

Handle tools/list request

Return type:

dict

to_json_rpc_handler()[source]

Create a JSON-RPC handler for MCP protocol

Return type:

Callable

Returns:

Handler function that processes JSON-RPC requests

class ayn.MCPTool(name, description, input_schema, handler=None)[source]

Bases: object

MCP tool definition

Example

>>> tool = MCPTool(
...     name="search",
...     description="Search for information",
...     input_schema={"type": "object", "properties": {"query": {"type": "string"}}}
... )
>>> tool.name
'search'
to_dict()[source]

Convert to MCP tool format

Return type:

dict

ayn.controller_to_mcp_server(controller, metadata, *, tools=None, resources=None, prompts=None)[source]

Convert an agent controller to MCP server

Parameters:
Return type:

MCPServer

Returns:

MCP server instance

Example

>>> from ayn.controllers import GenericController
>>> from ayn.core import AgentMetadata, AgentFramework, ControllerConfig
>>> meta = AgentMetadata(name="test", description="test", framework=AgentFramework.CUSTOM)
>>> controller = GenericController(meta, ControllerConfig())
>>> server = controller_to_mcp_server(controller, meta)
>>> server.name
'test'
ayn.create_agent_from_registry(registry, query, config=None)[source]

Search registry and create agent controller

Parameters:
Return type:

BaseAgentController

Returns:

Agent controller

Example

>>> from ayn import AgentRegistry
>>> from ayn.core import AgentMetadata, AgentFramework
>>> import tempfile
>>> registry = AgentRegistry(searchers=[], cache_dir=tempfile.mkdtemp())
>>> meta = AgentMetadata(name="test-agent", description="test", framework=AgentFramework.CUSTOM)
>>> registry['test-agent'] = meta
>>> controller = create_agent_from_registry(registry, 'test')
>>> isinstance(controller, BaseAgentController)
True
ayn.export_agent_full_stack(controller, metadata, *, api_host='0.0.0.0', api_port=8000, export_fastapi=True, export_mcp=True, export_chatgpt=True, mcp_tools=None)[source]

Export agent with all integrations

Parameters:
  • controller (AgentController) – Agent controller

  • metadata (AgentMetadata) – Agent metadata

  • api_host (str) – API host

  • api_port (int) – API port

  • export_fastapi (bool) – Whether to export as FastAPI

  • export_mcp (bool) – Whether to export as MCP server

  • export_chatgpt (bool) – Whether to generate ChatGPT action

  • mcp_tools (Optional[List[MCPTool]]) – Optional MCP tools

Return type:

dict

Returns:

Dict with export artifacts

Example

>>> from ayn.controllers import GenericController
>>> from ayn.core import AgentMetadata, AgentFramework, ControllerConfig
>>> meta = AgentMetadata(name="test", description="test", framework=AgentFramework.CUSTOM)
>>> controller = GenericController(meta, ControllerConfig())
>>> artifacts = export_agent_full_stack(
...     controller, meta,
...     export_fastapi=False, export_mcp=False, export_chatgpt=True
... )
>>> 'chatgpt_action' in artifacts
True
ayn.export_as_fastapi(controller, metadata=None, host='0.0.0.0', port=8000)[source]

Export agent controller as FastAPI service

Parameters:

Example

>>> # This would start a server - doctest: +SKIP
>>> controller = GenericController(...)
>>> export_as_fastapi(controller, port=8080)
ayn.export_as_langserve(controller, metadata=None)[source]

Export agent as LangServe compatible service

Parameters:
Return type:

Any

Returns:

LangServe app

Example

>>> # Requires langserve - doctest: +SKIP
>>> controller = GenericController(...)
>>> app = export_as_langserve(controller)
ayn.generate_chatgpt_action(controller, metadata, api_url)[source]

Generate ChatGPT custom action configuration

Parameters:
Return type:

dict

Returns:

ChatGPT action configuration

Example

>>> from ayn.controllers import GenericController
>>> from ayn.core import AgentMetadata, AgentFramework, ControllerConfig
>>> meta = AgentMetadata(name="test", description="test", framework=AgentFramework.CUSTOM)
>>> controller = GenericController(meta, ControllerConfig())
>>> action = generate_chatgpt_action(controller, meta, "https://api.example.com")
>>> action['schema']['info']['title']
'test'
ayn.generate_claude_mcp_config(mcp_server, server_url, transport='sse')[source]

Generate Claude Desktop MCP configuration

Parameters:
  • mcp_server (MCPServer) – MCP server instance

  • server_url (str) – URL where MCP server is hosted

  • transport (str) – Transport type (sse, stdio)

Return type:

dict

Returns:

Claude Desktop MCP config

Example

>>> from ayn.mcp import MCPServer
>>> server = MCPServer("test")
>>> config = generate_claude_mcp_config(server, "http://localhost:8000")
>>> config['mcpServers']['test']['url']
'http://localhost:8000/sse'

Modules

actions

Custom actions for ChatGPT and Claude.

controllers

Agent controllers for invoking agents.

core

Core data models and configuration for AYN.

export

Export agents as HTTP/REST services.

mcp

Model Context Protocol support.

registry

Agent registry and search functionality.

utils

Convenience utility functions.