What You'll Build
In this tutorial, you'll create your first AI agent and register it with MeshCore, making it discoverable and callable by other agents in the mesh. By the end, you'll have:
- A working AI agent registered in MeshCore
- Understanding of the agent lifecycle (register → discover → call)
- Hands-on experience with the Mesh CLI
- A foundation for building multi-agent workflows
Prerequisites:
- Node.js 16+ installed
- Basic command line knowledge
- 15-20 minutes of your time
What you'll learn:
- How to install and configure the Mesh CLI
- How to register your first agent
- How to discover and call other agents
- Best practices for agent metadata and pricing
Why Build with MeshCore?
Before we dive in, let's understand what makes MeshCore different from building standalone AI agents.
The Traditional Approach
Imagine you're building a content creation pipeline with multiple AI capabilities:
Your App → Manual integration with:
├─ GPT-4 API (for content generation)
├─ Custom summarization service
├─ Translation API
├─ Image generation API
└─ Custom fact-checking service
The problems:
- You manually integrate each API (different auth, formats, SDKs)
- You build your own usage tracking and billing
- You can't easily swap services or add new ones
- Each integration takes days or weeks
The MeshCore Approach
With MeshCore, your agents join a service mesh:
Your App → MeshCore Gateway → Automatically discover:
├─ Any content generation agent
├─ Any summarization agent
├─ Any translation agent
├─ Any image generation agent
└─ Any fact-checking agent
The benefits:
- One integration point (MeshCore gateway)
- Automatic billing and usage tracking
- Dynamic discovery (agents find the best service)
- Add new capabilities in minutes, not days
Let's build this.
Part 1: Setting Up Your Environment
Step 1: Install the Mesh CLI
The Mesh CLI is your command center for managing agents. Install it globally:
npm install -g @meshcore/cli
Verify the installation:
mesh --version
You should see something like @meshcore/cli v1.2.0
.
Step 2: Get Your Access Token
To interact with MeshCore, you need an authentication token:
- Go to meshcore.ai
- Sign up or log in
- Navigate to Settings → API Keys
- Click "Generate New Token"
- Copy your token (you won't see it again!)
Security tip: Never commit tokens to git. We'll store it securely in the next step.
Step 3: Authenticate
Login with your token:
mesh auth login
When prompted, paste your authentication token. The CLI will securely store it in your local configuration.
Verify authentication:
mesh auth status
You should see: ✅ Authenticated as: your-email@example.com
Part 2: Understanding Agent Types
Before creating an agent, let's understand the three agent types in MeshCore:
1. AGENT (General-Purpose AI Agents)
Autonomous AI systems that can reason, plan, and execute complex tasks.
Examples:
- Research assistant that gathers and synthesizes information
- Content writer that generates blog posts
- Data analyst that processes and visualizes data
When to use: You're building a complete AI system with reasoning capabilities.
2. TOOL (Specialized APIs and Services)
Single-purpose services that perform specific functions.
Examples:
- Weather forecast API
- PDF generation service
- Data validation tool
- Translation API
When to use: You have a specific utility or API to expose.
3. LLM (Large Language Models)
Raw language model endpoints for text generation, completion, and chat.
Examples:
- GPT-4 endpoint
- Claude API
- Local Llama model
When to use: You're exposing a language model for direct text generation.
For this tutorial, we'll create a TOOL type agent (a weather forecast service).
Part 3: Creating Your First Agent
Option A: Register an Existing Service
If you already have an API or service running, you can register it with MeshCore.
Let's say you have a weather API at https://api.myweather.com
with this endpoint:
GET /forecast?location={city}&days={number}
Register it:
mesh agent create \
--name "Weather Forecast Pro" \
--description "Real-time weather forecasts with 7-day predictions" \
--category "utilities" \
--type "TOOL" \
--endpoint "https://api.myweather.com" \
--price-per-call 0.001
What just happened?
--name
: Human-readable agent name (1-100 characters)--description
: What your agent does (1-1000 characters)--category
: Category for discovery (e.g., utilities, data, content, analysis)--type
: Agent type (AGENT, TOOL, or LLM)--endpoint
: Your service's base URL--price-per-call
: Cost in USD per API call ($0.001 = $1 per 1,000 calls)
The CLI will output your new agent ID:
✅ Agent created successfully!
Agent ID: abc123-def456-ghi789
Name: Weather Forecast Pro
Type: TOOL
Endpoint: https://api.myweather.com
Save this Agent ID - you'll need it to call your agent.
Option B: Register from a README
If your project has a README with API documentation, MeshCore can extract metadata automatically using AI.
mesh agent create ./path/to/your-project
The CLI will:
- Parse your README.md
- Extract name, description, and capabilities using AI
- Show you a preview of the metadata
- Let you edit and confirm before creating
Example:
mesh agent create ./my-weather-api
# CLI output:
📄 Found README.md
🤖 Extracting metadata with AI...
Preview:
Name: Weather API
Description: RESTful API for weather forecasts with 7-day predictions
Category: utilities
Type: AGENT (you can change this)
✏️ Edit this information? (Y/n):
Type Y
to edit, then change the type to TOOL
for a specialized service.
Part 4: Calling Your Agent (and Others!)
Now that your agent is registered, let's see how agents discover and call each other.
Discovering Agents
Find all weather-related agents in the mesh:
mesh agent list --category utilities
Or search programmatically using the Mesh SDK (Python example):
from mesh_sdk import MeshClient
client = MeshClient(api_key="your-token-here")
# Find weather agents
weather_agents = client.list_agents(category="utilities")
for agent in weather_agents:
print(f"Found: {agent.name} - ${agent.price_per_call} per call")
Calling an Agent
Once you have an agent ID, calling it is simple.
Using the CLI:
mesh agent call abc123-def456-ghi789 \
--input '{"location": "San Francisco", "days": 7}'
Using the Python SDK:
from mesh_sdk import MeshClient
client = MeshClient(api_key="your-token-here")
# Call the weather agent
response = client.call_agent(
agent_id="abc123-def456-ghi789",
inputs={
"location": "San Francisco",
"days": 7
}
)
print(response.data)
# Output: {"forecast": [...], "temperature": [...], ...}
What happens behind the scenes:
- Your request goes to the MeshCore gateway
- Gateway validates authentication and billing
- Gateway routes to the agent's endpoint
- Agent processes the request
- Response is returned through the gateway
- Usage is tracked and billed automatically
You never had to:
- Build authentication
- Track usage
- Implement retry logic
- Handle rate limiting
- Set up billing
MeshCore handles it all.
Part 5: Building a Multi-Agent Workflow
Let's combine multiple agents into an intelligent workflow. We'll build a Travel Planner Agent that orchestrates multiple specialized agents.
The Workflow
User: "Plan a 3-day trip to Paris"
↓
Travel Planner Agent (Orchestrator)
↓
┌───────┴────────┐
↓ ↓
Weather Agent Flight Search Agent
↓ ↓
"Sunny, 75°F" "Best price: $450"
└────────┬────────┘
↓
Hotel Agent
↓
"3 hotels near attractions"
↓
Activity Agent
↓
"Top activities for sunny weather"
↓
Final itinerary
Implementation
Here's a Python example using LangChain integration:
from mesh_sdk import MeshClient
from langchain.agents import initialize_agent, AgentType
from langchain.llms import OpenAI
from langchain.tools import Tool
# Initialize Mesh client
mesh_client = MeshClient(api_key="your-token")
# Discover agents in the mesh
weather_agents = mesh_client.list_agents(category="weather")
flight_agents = mesh_client.list_agents(category="travel")
hotel_agents = mesh_client.list_agents(category="accommodation")
# Wrap mesh agents as LangChain tools
def call_weather_agent(location: str) -> str:
"""Get weather forecast for a location."""
response = mesh_client.call_agent(
agent_id=weather_agents[0].id,
inputs={"location": location, "days": 7}
)
return response.data
def call_flight_agent(origin: str, destination: str, dates: str) -> str:
"""Search for flights."""
response = mesh_client.call_agent(
agent_id=flight_agents[0].id,
inputs={
"origin": origin,
"destination": destination,
"dates": dates
}
)
return response.data
# Create LangChain tools
tools = [
Tool(
name="WeatherForecast",
func=call_weather_agent,
description="Get 7-day weather forecast for a city"
),
Tool(
name="FlightSearch",
func=call_flight_agent,
description="Search for available flights between cities"
),
# Add more tools...
]
# Create orchestrator agent
llm = OpenAI(temperature=0)
agent = initialize_agent(
tools,
llm,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True
)
# Run the workflow
result = agent.run(
"Plan a 3-day trip to Paris for next week. "
"I need weather info, flight options from NYC, and hotel recommendations."
)
print(result)
Output:
Planning your trip to Paris...
Weather: Partly cloudy, 68-72°F
Flights: Best option $487 on Air France (direct)
Hotels: 3 options near Eiffel Tower ($150-$300/night)
Activities: Louvre, Seine cruise, Montmartre (good for partly cloudy weather)
Estimated total cost: $1,200-$1,500 for 3 days
Part 6: Best Practices
1. Set Appropriate Pricing
Price your agent based on:
- Computational cost
- External API costs (if any)
- Desired profit margin
Example pricing:
- Simple data lookups: $0.0001 - $0.001 per call
- LLM completions: $0.001 - $0.01 per call
- Complex processing: $0.01 - $0.10 per call
MeshCore takes a 10% platform fee, so if you charge $0.001, you earn $0.0009 per call.
2. Write Clear Descriptions
Good descriptions help agents discover your service:
❌ Bad: "API for stuff" ✅ Good: "Real-time weather forecasts with 7-day predictions, hourly breakdowns, and severe weather alerts for 50,000+ cities worldwide"
3. Choose the Right Category
Categories help with discovery:
- utilities: Tools, APIs, data services
- content: Writing, generation, summarization
- analysis: Data processing, insights, visualization
- communication: Translation, chat, notifications
- automation: Workflows, scheduling, integration
4. Document Your API
Keep your README up-to-date with:
- Clear endpoint documentation
- Input/output examples
- Authentication requirements
- Error handling
The CLI can auto-rewrite your README for MeshCore compatibility:
mesh agent create ./my-project --auto-rewrite
This updates your README with MeshCore gateway URLs and usage examples.
5. Monitor Usage
Check your agent's performance:
mesh agent get <agent-id>
This shows:
- Total calls
- Revenue generated
- Average response time
- Error rate
Part 7: What's Next?
Level Up Your Agent
Add more capabilities:
mesh agent update <agent-id> \
--description "Updated description with new features" \
--category "new-category"
Monitor health:
mesh health check <agent-id>
View analytics:
mesh agent get <agent-id> --json
Build Advanced Workflows
Explore orchestration patterns:
- Sequential workflows (A → B → C)
- Parallel execution (A + B → C)
- Conditional routing (if/else logic)
- Error handling and retries
Use the Python SDK for more control:
from mesh_sdk import MeshClient
async with MeshClient(api_key="your-token") as client:
# Async agent calls
agents = await client.list_agents_async()
# Stream responses
async for chunk in client.chat_completions(
model="gpt-4",
messages=[{"role": "user", "content": "Hello"}],
stream=True
):
print(chunk.choices[0].delta.content)
Join the Community
Connect with other builders:
- Discord: discord.gg/8GksNwCAC3 - 650K+ developer community
- Twitter: @meshcore_ai - Daily tips and updates
- GitHub: github.com/meshcore - Example agents and integrations
Explore Example Agents
Check out production examples:
- LangChain Orchestrator - Multi-agent coordination
- CrewAI Integration - Team-based workflows
- Runway ML API Connector - Video generation agent
Real-World Use Cases
1. Content Pipeline
Create a content factory with multiple specialized agents:
# Orchestrate content creation
research_agent = mesh.discover("research_assistant")
writer_agent = mesh.discover("content_writer")
editor_agent = mesh.discover("content_editor")
seo_agent = mesh.discover("seo_optimizer")
# Pipeline
research = research_agent.run({"topic": "AI trends 2025"})
draft = writer_agent.run({"research": research, "length": "1500 words"})
edited = editor_agent.run({"content": draft})
final = seo_agent.run({"content": edited, "target_keywords": ["AI", "machine learning"]})
2. Data Processing Workflow
Build intelligent data pipelines:
# Multi-agent data processing
validator = mesh.discover("data_validator")
cleaner = mesh.discover("data_cleaner")
analyzer = mesh.discover("data_analyzer")
visualizer = mesh.discover("chart_generator")
# Process data through pipeline
validated = validator.run(raw_data)
cleaned = cleaner.run(validated)
insights = analyzer.run(cleaned)
charts = visualizer.run(insights)
3. Customer Support Automation
Combine agents for intelligent support:
# Support workflow
classifier = mesh.discover("ticket_classifier")
kb_search = mesh.discover("knowledge_base_search")
responder = mesh.discover("response_generator")
sentiment = mesh.discover("sentiment_analyzer")
# Handle ticket
ticket_type = classifier.run(ticket_content)
relevant_docs = kb_search.run(ticket_type)
response = responder.run({"ticket": ticket_content, "docs": relevant_docs})
mood = sentiment.run(ticket_content) # Escalate if negative
Troubleshooting
Common Issues
"Authentication failed"
# Re-authenticate
mesh auth logout
mesh auth login
"Agent not found"
# List your agents
mesh agent list
# Verify agent ID is correct
mesh agent get <agent-id>
"Insufficient balance"
# Check your account balance at meshcore.ai
# Add credits via Settings → Billing
"Agent creation failed"
# Check your input:
# - Name: 1-100 characters
# - Description: 1-1000 characters
# - Endpoint: Valid URL
# - Price: Positive number
Summary: What You've Learned
✅ Installed and configured the Mesh CLI ✅ Created your first agent and registered it in the mesh ✅ Understood agent types (AGENT, TOOL, LLM) ✅ Discovered and called other agents programmatically ✅ Built a multi-agent workflow with orchestration ✅ Learned best practices for pricing, descriptions, and monitoring
The Big Picture
You've just joined the AI agent economy. Your agent is now:
- Discoverable by thousands of other agents
- Earning revenue automatically from usage
- Part of an ecosystem where agents collaborate
What you built in 20 minutes would take weeks without MeshCore:
- Agent registration and discovery
- Authentication and authorization
- Usage tracking and billing
- Gateway routing and load balancing
- Health monitoring and observability
This is the power of service mesh architecture for AI agents.
Next Steps
1. Register your real agent - Take your existing service and make it mesh-enabled
2. Build an orchestrator - Create workflows that combine multiple agents
3. Monetize your capability - Start earning from every API call
4. Join the community - Share your agent on Discord and get feedback
5. Explore integrations - Connect with LangChain, CrewAI, or your favorite framework
Get Help
- Documentation: meshcore.ai/docs
- Discord Support: discord.gg/8GksNwCAC3
- Email: hello@meshcore.ai
- GitHub Issues: github.com/meshcore/mesh-cli/issues
Share Your Build
Built something cool? We want to hear about it!
- Tag us on Twitter: @meshcore_ai
- Post in Discord #showcase channel
- Submit your agent to our Featured Agents gallery
The best agent each month wins $100 in free credits.
Ready to build the future of AI collaboration?
Join 650K+ developers building on MeshCore: meshcore.ai
🤖 This tutorial was written with assistance from Claude Code. Co-Authored-By: Claude noreply@anthropic.com