Skip to main content
Glama

mcp-google-sheets

new-agent.ts1.78 kB
import {createTrigger,TriggerStrategy,PiecePropValueSchema,} from "@activepieces/pieces-framework"; import {DedupeStrategy,Polling,pollingHelper,} from "@activepieces/pieces-common"; import dayjs from "dayjs"; import { makeRequest } from "../common/client"; import { HttpMethod } from "@activepieces/pieces-common"; import { AgentXAuth } from "../common/auth"; type Agent = { id: string; name?: string; createdAt: string; }; const polling: Polling< PiecePropValueSchema<typeof AgentXAuth>, Record<string, never> > = { strategy: DedupeStrategy.TIMEBASED, items: async ({ auth }) => { const agents = (await makeRequest(auth, HttpMethod.GET, "/agents")) as Agent[]; const sortedAgents = agents.sort((a, b) => dayjs(b.createdAt).valueOf() - dayjs(a.createdAt).valueOf() ); return sortedAgents.map((agent) => ({ epochMilliSeconds: dayjs(agent.createdAt).valueOf(), data: agent, })); }, }; export const newAgent = createTrigger({ auth: AgentXAuth, name: "new_agent", displayName: "New Agent", description: "Triggers when a new AgentX agent is created.", props: {}, sampleData: { _id: "agt_1234567890abcdef", name: "Customer Support Bot", created_at: "2025-09-08T10:00:00Z", }, type: TriggerStrategy.POLLING, async test(context) { return await pollingHelper.test(polling, context); }, async onEnable(context) { const { store, auth, propsValue } = context; await pollingHelper.onEnable(polling, { store, auth, propsValue }); }, async onDisable(context) { const { store, auth, propsValue } = context; await pollingHelper.onDisable(polling, { store, auth, propsValue }); }, async run(context) { return await pollingHelper.poll(polling, context); }, });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/activepieces/activepieces'

If you have feedback or need assistance with the MCP directory API, please join our Discord server