Use this file to discover all available pages before exploring further.
FrontMCP agents are autonomous units that can invoke tools using LLM reasoning. This guide shows you how to create agents that combine LLM capabilities with your MCP tools.
// agents/summary.agent.tsimport { Agent, AgentContext } from '@frontmcp/sdk';import { z } from '@frontmcp/sdk';import GetWeatherTool from '../tools/get-weather.tool';@Agent({ name: 'weather-summary', systemInstructions: `You are a helpful weather assistant. When asked about weather:1. Use the get_weather tool to fetch current conditions2. Provide a friendly, conversational summary of the weather3. Include practical advice (e.g., "bring an umbrella" for rain)`, inputSchema: { location: z.string().describe('City name or location'), units: z.enum(['celsius', 'fahrenheit']).optional().describe('Temperature units'), }, outputSchema: { summary: z.string().describe('Weather summary for the given location'), }, // Configure the LLM provider llm: { provider: 'openai', model: 'gpt-4', apiKey: { env: 'OPENAI_API_KEY', // Read from environment variable }, }, // Make agent visible in tool listings codecall: { visibleInListTools: true, }, // Tools the agent can use tools: [GetWeatherTool],})export default class WeatherSummaryAgent extends AgentContext {}
codecall: { // Include in tools/list responses visibleInListTools: true, // Custom name for tool listing (default: agent name) toolName: 'summarize_weather',}
systemInstructions: `You are a helpful assistant that...- Always use available tools before responding- Provide concise, actionable responses- If you can't find information, say so clearly`,
import { Agent, AgentContext } from '@frontmcp/sdk';import { z } from '@frontmcp/sdk';import GetWeatherTool from '../tools/get-weather.tool';import GetForecastTool from '../tools/get-forecast.tool';import GetAlertsTool from '../tools/get-alerts.tool';@Agent({ name: 'travel-advisor', systemInstructions: `You are a travel weather advisor. Help users plan their trips by:1. Checking current weather at the destination2. Looking at the forecast for their travel dates3. Alerting them to any weather warnings4. Providing packing suggestions based on conditions`, inputSchema: { destination: z.string().describe('Travel destination'), departureDate: z.string().describe('Departure date (YYYY-MM-DD)'), returnDate: z.string().describe('Return date (YYYY-MM-DD)'), }, outputSchema: { recommendation: z.string().describe('Travel weather recommendation'), packingList: z.array(z.string()).describe('Suggested items to pack'), alerts: z.array(z.string()).optional().describe('Any weather alerts'), }, llm: { provider: 'openai', model: 'gpt-4', apiKey: { env: 'OPENAI_API_KEY' }, }, // Multiple tools available to the agent tools: [GetWeatherTool, GetForecastTool, GetAlertsTool],})export default class TravelAdvisorAgent extends AgentContext {}
@Agent({ name: 'expense-planner', systemInstructions: `You are an expense planning assistant. Help users:1. Categorize their expenses using available categories2. Check against budget limits3. Suggest ways to optimize spending4. Create expense reportsAlways use the tools to get accurate data before making recommendations.`, inputSchema: { query: z.string().describe('User question about expenses'), timeframe: z.enum(['week', 'month', 'quarter', 'year']).optional(), }, outputSchema: { response: z.string().describe('Response to the user query'), suggestedActions: z.array(z.string()).optional(), }, llm: { provider: 'anthropic', model: 'claude-3-sonnet-20240229', apiKey: { env: 'ANTHROPIC_API_KEY' }, }, tools: [ ListExpensesTool, GetCategoriesResource, GetBudgetTool, CreateReportTool, ],})export default class ExpensePlannerAgent extends AgentContext {}
// Good - specific and actionablesystemInstructions: `You are a customer support agent.1. Always greet the customer2. Use the search_orders tool to find relevant orders3. Never share sensitive data like full credit card numbers4. If you can't help, escalate to a human`,// Bad - too vaguesystemInstructions: 'Help customers with their questions'
Limit available tools
Only give agents tools they need:
// Good - focused set of toolstools: [GetOrderTool, TrackShipmentTool, RefundTool],// Bad - too many unrelated toolstools: [...allTools], // Agent might get confused
systemInstructions: `...If a tool call fails:1. Try an alternative approach if available2. Inform the user what went wrong3. Suggest next steps they can take`
Monitor agent costs
Track LLM API usage:
llm: { // Use cheaper models for simple tasks model: process.env.AGENT_MODEL || 'gpt-3.5-turbo', maxTokens: 500, // Limit response length}