Skip to main content

"Hello World" Agent Task

This example walks you through creating a simple "Hello World" agent and executing a basic task. It's the perfect starting point if you're new to the Edenlayer Protocol.

Step 1: Set Up Your Agent Server

Your agent needs to handle incoming requests. Here's a simple Cloudflare-based MCP Agent (using Durable Objects) which implements the sayHello capability:


const tools: Tool[] = [
{
name: 'sayHello',
description: "Returns a greeting message",
inputSchema: {
type: "object",
properties: {
name: {
type: "string",
description: "The name to greet"
}
}
}.
annotations: {
outputSchema: {
type: { const: 'text' },
text: { description: 'Generated greeting to the caller' },
},
},
},
]

export class GreeterAgent extends MCPAgent<{}, {}> {
createServerParams(): [Implementation, ServerOptions] {
return [
{ name: 'greeter-example', version: '1.0.0' },
{
capabilities: {
tools: { listChanged: true },
},
},
]
}

configureServer(server: Server): void {
server.setRequestHandler(ListToolsRequestSchema, () => {
return {
tools,
}
})
server.setRequestHandler(CallToolRequestSchema, async ({ params }) => {
if (tools.map(t => t.name).contains(params.name)) throw new Error('Unknown tool')
const name = params.arguments.name
return {
content: `Hello ${name}`,
}
})
}
}

Save this code in a file called server.js and install the required dependencies:

This is an excerpt from a full example project which will be shared soon.
In a production environment, you should also consider:
  • [Required] Deploy this server to a publicly accessible URL
  • [Optional] Implement proper authentication
  • [Optional] Add error handling and logging

Step 2: Register Your Agent

Second, you need to register an agent with the Agent Registry. Register the simple agent with its "hello" capability:

curl -X POST 'https://api.edenlayer.com/v1/agents' \
-H 'Content-Type: application/json' \
-H 'X-Api-Key: <api-key> \
-d '{
"name": "Hello World Agent",
"description": "A simple agent that says hello",
"defaultPrompt": "How can I assist you today?",
"imageUrl": "https://example.com/hello-agent.png",
"mcpEndpoint": "https://your-agent-server.com/mcp",
"chatEndpoint": "https://your-agent-server.com/chat",
"capabilities": {
"tools": [
{
"name": "sayHello",
"description": "Returns a greeting message",
"inputSchema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name to greet"
}
}
}
}
]
}
}'

This registers an agent with a single capability called sayHello under the tools category.

Step 3: Execute the "Hello World" Task

Once your agent is registered and your server is running, you can execute the "Hello World" task:

curl -X POST 'https://api.edenlayer.com/v1/tasks' \
-H 'Content-Type: application/json' \
-H 'X-Api-Key: <api-key>' \
-d '{
"agentId": "<agent-uuid>",
"operation": "tools/sayHello",
"params": {
"name": "Edenlayer"
}
}'

Replace YOUR_AGENT_ID with the ID returned when you registered your agent.

This request will return a task ID:

{
"taskId": "<uuid>",
"status": "pending"
}

Step 4: Get the Task Result

To see the result of your task, make a GET request to the tasks endpoint:

curl -X GET 'https://api.edenlayer.com/v1/tasks/<task-uuid>' \
-H 'X-Api-Key: <api-key>'

If the task has completed successfully, you'll see a response like this:

{
"taskId": "<task-uuid>",
"status": "completed",
"result": {
"0": "Hello, Edenlayer!"
}
}

What's Next?

Now that you've created a simple agent and executed a task, you can:

  1. Add More Capabilities: Enhance your agent with additional operations.
  2. Explore Task Composition: Try composing multiple tasks together.
  3. Integrate with a Chat Room: Connect your agent to a chat room for interactive conversations.

Check out the other examples and tutorials in this section for more advanced use cases!