amplemarket_get_article
Retrieve specific articles from the Amplemarket knowledge base using article ID or slug to access detailed content and information.
Instructions
Get a specific article from the Amplemarket knowledge base by ID or slug
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Article ID (provide either id or slug) | |
| slug | No | Article slug (provide either id or slug) |
Implementation Reference
- src/tools/kbGetArticle.ts:24-57 (handler)The asynchronous handler function that implements the core logic of the 'amplemarket_get_article' tool. It parses the input arguments, fetches the article from the Pylon API using either ID or slug, and returns the article as formatted JSON or an error message.export async function handleKbGetArticle(pylonClient: PylonAPI, args: unknown) { const params = GetArticleParamsSchema.parse(args); try { let article; if (params.id) { article = await pylonClient.getArticleById(params.id); } else if (params.slug) { article = await pylonClient.getArticleBySlug(params.slug); } else { throw new Error('Either id or slug must be provided'); } return { content: [ { type: 'text', text: JSON.stringify(article, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error getting article: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
- src/tools/kbGetArticle.ts:5-22 (schema)The tool definition object 'kbGetArticleTool' that specifies the name, description, and input schema for the MCP tool.export const kbGetArticleTool: Tool = { name: 'amplemarket_get_article', description: 'Get a specific article from the Amplemarket knowledge base by ID or slug', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Article ID (provide either id or slug)' }, slug: { type: 'string', description: 'Article slug (provide either id or slug)' } }, additionalProperties: false } };
- src/schema.ts:3-12 (schema)Zod schema 'GetArticleParamsSchema' used in the handler for input validation, ensuring either 'id' or 'slug' is provided.export const GetArticleParamsSchema = z.object({ id: z.string().optional(), slug: z.string().optional() }).refine( (data) => data.id || data.slug, { message: "Either 'id' or 'slug' must be provided", path: ["id"] } );
- src/index.ts:39-43 (registration)Registration of the tool in the MCP server's ListTools request handler by including 'kbGetArticleTool' in the returned tools list.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [kbGetArticleTool, kbGetCollectionTool, kbGetArticlesTool], }; });
- src/index.ts:45-56 (registration)Dispatch registration in the MCP server's CallTool request handler, mapping 'amplemarket_get_article' to the 'handleKbGetArticle' function.server.setRequestHandler(CallToolRequestSchema, async (request) => { switch (request.params.name) { case 'amplemarket_get_article': return await handleKbGetArticle(pylonClient, request.params.arguments); case 'kb_get_collection': return await handleKbGetCollection(pylonClient, request.params.arguments); case 'amplemarket_get_all_articles': return await handleKbGetArticles(pylonClient, request.params.arguments); default: throw new Error(`Unknown tool: ${request.params.name}`); } });