newsAlicante.ts•1.01 kB
import { z } from "zod";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { scrap } from "../shared/scrap.js";
export function registerNewsAlicante(server: McpServer) {
server.tool(
"news-alicante-informacion",
"Get the latest news from Alicante from informacion.es",
async () => {
const ctrl = new AbortController();
const id = setTimeout(() => ctrl.abort(), 8000);
try {
const headlines = await scrap("https://www.informacion.es/alicante/", {
signal: ctrl.signal,
});
return {
content: [
{
type: "text",
text: JSON.stringify({ headlines }, null, 2),
},
],
};
} catch (err: any) {
return {
content: [
{
type: "text",
text: JSON.stringify({ error: err.message }),
},
],
};
} finally {
clearTimeout(id);
}
}
);
}