theseoagent-mcp 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ First public release.
6
+
7
+ - stdio MCP server with 7 tools: `list_projects`, `list_articles`, `get_article`, `generate_article`, `keyword_research`, `run_audit`, `publish_article`.
8
+ - Long-running tools poll their job and send MCP progress notifications; on timeout they return `job_id` + `poll_url`.
9
+ - Starts and lists tools without an API key; tool calls explain how to set `THESEOAGENT_API_KEY`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The SEO Agent (theseoagent.ai)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,101 @@
1
- # Temporary Holding Version
1
+ # theseoagent-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [The SEO Agent](https://www.theseoagent.ai) as MCP tools. Plug it into Claude Code, Claude Desktop, or Cursor and your agent can run real keyword research, deep SEO audits, daily fact-checked article generation, and one-click CMS publishing as native tool calls.
4
+
5
+ No scraping, no estimates. The tools hit the same live API the product runs on: real keyword data, full-crawl audits with AI-content scoring, articles that go through a fact-check and quality gate before they exist, and native publishing to WordPress, Webflow, Shopify, Wix, Ghost, or a webhook.
6
+
7
+ ## Install
8
+
9
+ You need Node 18+ and an API key (see [Getting a key](#getting-a-key)).
10
+
11
+ ### Claude Code
12
+
13
+ ```sh
14
+ claude mcp add theseoagent -e THESEOAGENT_API_KEY=sk_live_... -- npx -y theseoagent-mcp
15
+ ```
16
+
17
+ ### Claude Desktop
18
+
19
+ Add to `claude_desktop_config.json`:
20
+
21
+ ```json
22
+ {
23
+ "mcpServers": {
24
+ "theseoagent": {
25
+ "command": "npx",
26
+ "args": ["-y", "theseoagent-mcp"],
27
+ "env": {
28
+ "THESEOAGENT_API_KEY": "sk_live_..."
29
+ }
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ ### Cursor
36
+
37
+ Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
38
+
39
+ ```json
40
+ {
41
+ "mcpServers": {
42
+ "theseoagent": {
43
+ "command": "npx",
44
+ "args": ["-y", "theseoagent-mcp"],
45
+ "env": {
46
+ "THESEOAGENT_API_KEY": "sk_live_..."
47
+ }
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ ## Tools
54
+
55
+ | Tool | What it does | Caps |
56
+ | ------------------ | -------------------------------------------------------------------------------------------------------- | ------------------------- |
57
+ | `list_projects` | List your projects (sites) with id, domain, status. | - |
58
+ | `list_articles` | List generated articles (title, slug, status, word count, scores, published URL) with cursor pagination. | - |
59
+ | `get_article` | Fetch one article by id, including full markdown/HTML content and meta description. | - |
60
+ | `generate_article` | Queue a fact-checked article for a keyword and poll to completion (up to 20 min). | 1 article / project / day |
61
+ | `keyword_research` | Run the full keyword pipeline on a project: live keyword data, clustering, article planning. | 10 runs / day |
62
+ | `run_audit` | Deep SEO audit of any domain. Returns a shareable report URL. | 5 audits / day |
63
+ | `publish_article` | Push a generated article to the project's connected CMS. Synchronous. | - |
64
+
65
+ Long-running tools (`generate_article`, `keyword_research`, `run_audit`) poll the job server-side and send MCP progress notifications while they wait. If a job outlives the polling window, the tool returns the `job_id` and `poll_url` so you can check on it later instead of losing the run.
66
+
67
+ ## Getting a key
68
+
69
+ 1. Create an account at [theseoagent.ai/signup](https://www.theseoagent.ai/signup) and start the trial.
70
+ 2. Mint a key (org admin only) at [theseoagent.ai/settings/api-keys](https://www.theseoagent.ai/settings/api-keys). The key is shown once, so copy it then.
71
+ 3. Set it as `THESEOAGENT_API_KEY` (format `sk_live_...`).
72
+
73
+ API calls need an active plan: $1 for a 3-day trial, then $99/mo. Cancel in-app, instantly, no email required. Without a key the server still starts and lists its tools, so you can check the setup first.
74
+
75
+ ## Configuration
76
+
77
+ | Env var | Required | Default | What it does |
78
+ | ---------------------- | -------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------ |
79
+ | `THESEOAGENT_API_KEY` | Yes (for tool calls) | - | Your `sk_live_...` API key. The server starts without it, but every tool call will tell you to set it. |
80
+ | `THESEOAGENT_API_BASE` | No | `https://www.theseoagent.ai/api/v1` | Override the API base URL. You almost never want this. |
81
+
82
+ ## Example prompts
83
+
84
+ Once the server is connected, ask your agent things like:
85
+
86
+ - "List my SEO Agent projects."
87
+ - "Run an SEO audit on example.com and give me the report link."
88
+ - "Run keyword research on my project, then write an article for the best keyword."
89
+ - "Publish the article you just generated to my site."
90
+
91
+ ## Raw REST API
92
+
93
+ Everything these tools do is also available as plain REST: [theseoagent.ai/docs/api](https://www.theseoagent.ai/docs/api).
94
+
95
+ ## Version history
96
+
97
+ See [CHANGELOG.md](CHANGELOG.md).
98
+
99
+ ## License
100
+
101
+ MIT
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Minimal fetch client for The SEO Agent public REST API (v1).
3
+ *
4
+ * - Base URL from THESEOAGENT_API_BASE (default https://www.theseoagent.ai/api/v1)
5
+ * - Auth via Authorization: Bearer <THESEOAGENT_API_KEY>
6
+ * - Unwraps the { data, request_id } envelope
7
+ * - Throws a typed ApiError on { error, request_id } envelopes
8
+ *
9
+ * Node 18+ global fetch. No dependencies.
10
+ */
11
+ export declare const DEFAULT_BASE_URL = "https://www.theseoagent.ai/api/v1";
12
+ export interface ApiErrorBody {
13
+ code: string;
14
+ message: string;
15
+ [key: string]: unknown;
16
+ }
17
+ export declare class ApiError extends Error {
18
+ readonly status: number;
19
+ readonly code: string;
20
+ readonly requestId: string | null;
21
+ /** Extra fields the error envelope carried (e.g. job_id, poll_url, retry_after_seconds). */
22
+ readonly extras: Record<string, unknown>;
23
+ /** Populated on 429 responses, in seconds. */
24
+ readonly retryAfterSeconds: number | null;
25
+ constructor(args: {
26
+ status: number;
27
+ code: string;
28
+ message: string;
29
+ requestId: string | null;
30
+ extras?: Record<string, unknown>;
31
+ retryAfterSeconds?: number | null;
32
+ });
33
+ }
34
+ export interface ApiResponse<T> {
35
+ data: T;
36
+ requestId: string | null;
37
+ }
38
+ export interface ClientOptions {
39
+ apiKey: string;
40
+ baseUrl?: string;
41
+ }
42
+ export declare class TheSeoAgentClient {
43
+ private readonly apiKey;
44
+ private readonly baseUrl;
45
+ constructor(options: ClientOptions);
46
+ get<T>(path: string, query?: Record<string, string | number | undefined>): Promise<ApiResponse<T>>;
47
+ post<T>(path: string, body?: unknown): Promise<ApiResponse<T>>;
48
+ private request;
49
+ }
package/dist/client.js ADDED
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Minimal fetch client for The SEO Agent public REST API (v1).
3
+ *
4
+ * - Base URL from THESEOAGENT_API_BASE (default https://www.theseoagent.ai/api/v1)
5
+ * - Auth via Authorization: Bearer <THESEOAGENT_API_KEY>
6
+ * - Unwraps the { data, request_id } envelope
7
+ * - Throws a typed ApiError on { error, request_id } envelopes
8
+ *
9
+ * Node 18+ global fetch. No dependencies.
10
+ */
11
+ export const DEFAULT_BASE_URL = 'https://www.theseoagent.ai/api/v1';
12
+ export class ApiError extends Error {
13
+ status;
14
+ code;
15
+ requestId;
16
+ /** Extra fields the error envelope carried (e.g. job_id, poll_url, retry_after_seconds). */
17
+ extras;
18
+ /** Populated on 429 responses, in seconds. */
19
+ retryAfterSeconds;
20
+ constructor(args) {
21
+ super(args.message);
22
+ this.name = 'ApiError';
23
+ this.status = args.status;
24
+ this.code = args.code;
25
+ this.requestId = args.requestId;
26
+ this.extras = args.extras ?? {};
27
+ this.retryAfterSeconds = args.retryAfterSeconds ?? null;
28
+ }
29
+ }
30
+ export class TheSeoAgentClient {
31
+ apiKey;
32
+ baseUrl;
33
+ constructor(options) {
34
+ this.apiKey = options.apiKey;
35
+ this.baseUrl = (options.baseUrl ??
36
+ process.env.THESEOAGENT_API_BASE ??
37
+ DEFAULT_BASE_URL).replace(/\/+$/, '');
38
+ }
39
+ async get(path, query) {
40
+ return this.request('GET', path, undefined, query);
41
+ }
42
+ async post(path, body) {
43
+ return this.request('POST', path, body);
44
+ }
45
+ async request(method, path, body, query) {
46
+ let url = `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;
47
+ if (query) {
48
+ const params = new URLSearchParams();
49
+ for (const [key, value] of Object.entries(query)) {
50
+ if (value !== undefined && value !== null && value !== '') {
51
+ params.set(key, String(value));
52
+ }
53
+ }
54
+ const qs = params.toString();
55
+ if (qs)
56
+ url += `?${qs}`;
57
+ }
58
+ let res;
59
+ try {
60
+ res = await fetch(url, {
61
+ method,
62
+ headers: {
63
+ Authorization: `Bearer ${this.apiKey}`,
64
+ 'X-Integration-Source': 'mcp',
65
+ ...(body !== undefined ? { 'Content-Type': 'application/json' } : {}),
66
+ },
67
+ body: body !== undefined ? JSON.stringify(body) : undefined,
68
+ });
69
+ }
70
+ catch (err) {
71
+ throw new ApiError({
72
+ status: 0,
73
+ code: 'network_error',
74
+ message: `Could not reach ${url}: ${err instanceof Error ? err.message : String(err)}`,
75
+ requestId: null,
76
+ });
77
+ }
78
+ let parsed = null;
79
+ const text = await res.text();
80
+ if (text) {
81
+ try {
82
+ parsed = JSON.parse(text);
83
+ }
84
+ catch {
85
+ parsed = null;
86
+ }
87
+ }
88
+ const envelope = (parsed ?? {});
89
+ const requestId = typeof envelope.request_id === 'string' ? envelope.request_id : null;
90
+ if (!res.ok || envelope.error) {
91
+ const errBody = envelope.error;
92
+ const { code, message, ...extras } = errBody ?? {
93
+ code: `http_${res.status}`,
94
+ message: text ? text.slice(0, 300) : `HTTP ${res.status}`,
95
+ };
96
+ const retryAfterHeader = res.headers.get('Retry-After');
97
+ const retryFromBody = typeof extras['retry_after_seconds'] === 'number'
98
+ ? extras['retry_after_seconds']
99
+ : null;
100
+ const retryAfterSeconds = res.status === 429
101
+ ? (retryFromBody ??
102
+ (retryAfterHeader ? Number.parseInt(retryAfterHeader, 10) || null : null))
103
+ : null;
104
+ throw new ApiError({
105
+ status: res.status,
106
+ code: typeof code === 'string' ? code : `http_${res.status}`,
107
+ message: typeof message === 'string' ? message : `HTTP ${res.status}`,
108
+ requestId,
109
+ extras,
110
+ retryAfterSeconds,
111
+ });
112
+ }
113
+ return { data: envelope.data, requestId };
114
+ }
115
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * theseoagent-mcp: stdio MCP server exposing The SEO Agent's public REST API
4
+ * (https://www.theseoagent.ai/api/v1) as MCP tools.
5
+ *
6
+ * IMPORTANT: stdout is the JSON-RPC protocol channel. All diagnostics go to stderr.
7
+ */
8
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * theseoagent-mcp: stdio MCP server exposing The SEO Agent's public REST API
4
+ * (https://www.theseoagent.ai/api/v1) as MCP tools.
5
+ *
6
+ * IMPORTANT: stdout is the JSON-RPC protocol channel. All diagnostics go to stderr.
7
+ */
8
+ import { createRequire } from 'node:module';
9
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
10
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
11
+ import { registerTools } from './tools.js';
12
+ // Read the version from package.json (always in the npm tarball, one level up
13
+ // from dist/) so serverInfo.version can never drift from the published version.
14
+ const { version } = createRequire(import.meta.url)('../package.json');
15
+ async function main() {
16
+ const server = new McpServer({
17
+ name: 'theseoagent',
18
+ version,
19
+ });
20
+ registerTools(server);
21
+ if (!process.env.THESEOAGENT_API_KEY) {
22
+ console.error('[theseoagent-mcp] THESEOAGENT_API_KEY is not set. The server will start, but tool calls will fail until you set it. Mint a key at https://www.theseoagent.ai/settings/api-keys');
23
+ }
24
+ const transport = new StdioServerTransport();
25
+ await server.connect(transport);
26
+ console.error('[theseoagent-mcp] ready on stdio');
27
+ }
28
+ main().catch((err) => {
29
+ console.error('[theseoagent-mcp] fatal:', err);
30
+ process.exit(1);
31
+ });
package/dist/jobs.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Job polling for the async agent endpoints (/agents/generate, /agents/keyword-research, /agents/audit).
3
+ *
4
+ * Polls GET /jobs/:id until the job reaches a terminal status (succeeded | failed | canceled),
5
+ * waiting out 429s using retry_after_seconds. On overall timeout it does NOT throw: it returns
6
+ * the last seen job state with timedOut=true so the caller can hand back job_id + poll_url.
7
+ */
8
+ import { TheSeoAgentClient } from './client.js';
9
+ export interface Job {
10
+ id: string;
11
+ status: 'pending' | 'running' | 'succeeded' | 'failed' | 'canceled' | string;
12
+ current_stage?: string | null;
13
+ error?: string | null;
14
+ [key: string]: unknown;
15
+ }
16
+ export declare function isTerminal(status: string | undefined): boolean;
17
+ export interface PollOptions {
18
+ /** Overall wall-clock budget in milliseconds. */
19
+ timeoutMs: number;
20
+ /** Delay between polls in milliseconds. Default 5000. */
21
+ intervalMs?: number;
22
+ /** Best-effort progress callback. Failures inside it are ignored by the caller's wrapper. */
23
+ onProgress?: (message: string) => void | Promise<void>;
24
+ }
25
+ export interface PollResult {
26
+ job: Job | null;
27
+ timedOut: boolean;
28
+ /** Milliseconds elapsed while polling. */
29
+ elapsedMs: number;
30
+ }
31
+ export declare function pollJob(client: TheSeoAgentClient, jobId: string, opts: PollOptions): Promise<PollResult>;
package/dist/jobs.js ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Job polling for the async agent endpoints (/agents/generate, /agents/keyword-research, /agents/audit).
3
+ *
4
+ * Polls GET /jobs/:id until the job reaches a terminal status (succeeded | failed | canceled),
5
+ * waiting out 429s using retry_after_seconds. On overall timeout it does NOT throw: it returns
6
+ * the last seen job state with timedOut=true so the caller can hand back job_id + poll_url.
7
+ */
8
+ import { ApiError } from './client.js';
9
+ const TERMINAL_STATUSES = new Set(['succeeded', 'failed', 'canceled']);
10
+ export function isTerminal(status) {
11
+ return status !== undefined && TERMINAL_STATUSES.has(status);
12
+ }
13
+ function sleep(ms) {
14
+ return new Promise((resolve) => setTimeout(resolve, ms));
15
+ }
16
+ export async function pollJob(client, jobId, opts) {
17
+ const intervalMs = opts.intervalMs ?? 5000;
18
+ const startedAt = Date.now();
19
+ let lastJob = null;
20
+ let consecutiveErrors = 0;
21
+ for (;;) {
22
+ const elapsedMs = Date.now() - startedAt;
23
+ if (elapsedMs >= opts.timeoutMs) {
24
+ return { job: lastJob, timedOut: true, elapsedMs };
25
+ }
26
+ try {
27
+ const { data } = await client.get(`/jobs/${jobId}`);
28
+ lastJob = data.job;
29
+ consecutiveErrors = 0;
30
+ if (isTerminal(lastJob.status)) {
31
+ return { job: lastJob, timedOut: false, elapsedMs: Date.now() - startedAt };
32
+ }
33
+ if (opts.onProgress) {
34
+ const stage = lastJob.current_stage ? ` stage=${lastJob.current_stage}` : '';
35
+ const minutes = Math.floor((Date.now() - startedAt) / 60000);
36
+ const seconds = Math.floor(((Date.now() - startedAt) % 60000) / 1000);
37
+ await opts.onProgress(`status=${lastJob.status}${stage} elapsed=${minutes}m${seconds}s`);
38
+ }
39
+ }
40
+ catch (err) {
41
+ if (err instanceof ApiError && err.status === 429) {
42
+ const waitSeconds = err.retryAfterSeconds ?? Math.ceil(intervalMs / 1000);
43
+ await sleep(Math.min(waitSeconds * 1000, Math.max(0, opts.timeoutMs - (Date.now() - startedAt))));
44
+ continue;
45
+ }
46
+ // Tolerate a few transient failures (network blip, 500) before giving up.
47
+ consecutiveErrors += 1;
48
+ if (consecutiveErrors >= 3) {
49
+ throw err;
50
+ }
51
+ }
52
+ const remaining = opts.timeoutMs - (Date.now() - startedAt);
53
+ if (remaining <= 0) {
54
+ return { job: lastJob, timedOut: true, elapsedMs: Date.now() - startedAt };
55
+ }
56
+ await sleep(Math.min(intervalMs, remaining));
57
+ }
58
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The 7 MCP tools exposed by theseoagent-mcp.
3
+ *
4
+ * Every tool talks to the live REST API at https://www.theseoagent.ai/api/v1.
5
+ * The server starts and serves tools/list even without THESEOAGENT_API_KEY;
6
+ * tool calls without a key return a clear isError result.
7
+ */
8
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
9
+ export declare function registerTools(server: McpServer): void;
package/dist/tools.js ADDED
@@ -0,0 +1,347 @@
1
+ /**
2
+ * The 7 MCP tools exposed by theseoagent-mcp.
3
+ *
4
+ * Every tool talks to the live REST API at https://www.theseoagent.ai/api/v1.
5
+ * The server starts and serves tools/list even without THESEOAGENT_API_KEY;
6
+ * tool calls without a key return a clear isError result.
7
+ */
8
+ import { z } from 'zod';
9
+ import { ApiError, TheSeoAgentClient } from './client.js';
10
+ import { isTerminal, pollJob } from './jobs.js';
11
+ const KEY_URL = 'https://www.theseoagent.ai/settings/api-keys';
12
+ const GENERATE_TIMEOUT_MS = 20 * 60 * 1000;
13
+ const KEYWORD_RESEARCH_TIMEOUT_MS = 12 * 60 * 1000;
14
+ const AUDIT_TIMEOUT_MS = 12 * 60 * 1000;
15
+ function getClient() {
16
+ const apiKey = process.env.THESEOAGENT_API_KEY;
17
+ if (!apiKey || !apiKey.trim())
18
+ return null;
19
+ return new TheSeoAgentClient({ apiKey: apiKey.trim() });
20
+ }
21
+ function jsonResult(payload, isError = false) {
22
+ return {
23
+ content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
24
+ ...(isError ? { isError: true } : {}),
25
+ };
26
+ }
27
+ function missingKeyResult() {
28
+ return jsonResult({
29
+ error: 'THESEOAGENT_API_KEY is not set',
30
+ fix: `Set the THESEOAGENT_API_KEY environment variable to your sk_live_... key. Mint one at ${KEY_URL}`,
31
+ }, true);
32
+ }
33
+ function apiErrorResult(err) {
34
+ if (err instanceof ApiError) {
35
+ return jsonResult({
36
+ error: {
37
+ code: err.code,
38
+ message: err.message,
39
+ status: err.status,
40
+ ...(Object.keys(err.extras).length > 0 ? { details: err.extras } : {}),
41
+ },
42
+ request_id: err.requestId,
43
+ }, true);
44
+ }
45
+ return jsonResult({
46
+ error: {
47
+ code: 'unexpected_error',
48
+ message: err instanceof Error ? err.message : String(err),
49
+ },
50
+ }, true);
51
+ }
52
+ /**
53
+ * Best-effort notifications/progress sender. Returns a callback that never throws;
54
+ * undefined when the client did not request progress (no progressToken).
55
+ */
56
+ function progressNotifier(extra, label) {
57
+ const progressToken = extra._meta?.progressToken;
58
+ if (progressToken === undefined)
59
+ return undefined;
60
+ let tick = 0;
61
+ return async (message) => {
62
+ try {
63
+ await extra.sendNotification({
64
+ method: 'notifications/progress',
65
+ params: { progressToken, progress: ++tick, message: `${label}: ${message}` },
66
+ });
67
+ }
68
+ catch {
69
+ // A failed notification must never kill the poll.
70
+ }
71
+ };
72
+ }
73
+ function timedOutPayload(jobId, pollUrl, lastJob, what) {
74
+ return {
75
+ timed_out: true,
76
+ job_id: jobId,
77
+ ...(pollUrl ? { poll_url: pollUrl } : {}),
78
+ last_known_state: lastJob,
79
+ note: `The ${what} is still running server-side. Check on it later with GET ${pollUrl ?? `/jobs/${jobId}`} (Authorization: Bearer <key>), or re-run this tool's read counterpart once it finishes.`,
80
+ };
81
+ }
82
+ export function registerTools(server) {
83
+ // 1. list_projects
84
+ server.registerTool('list_projects', {
85
+ title: 'List projects',
86
+ description: 'List the projects (sites) on your The SEO Agent account. Returns id, name, domain, status, default_language, created_at, updated_at for each project. Call this first to get a project_id for the other tools.',
87
+ inputSchema: {},
88
+ }, async () => {
89
+ const client = getClient();
90
+ if (!client)
91
+ return missingKeyResult();
92
+ try {
93
+ const { data, requestId } = await client.get('/projects');
94
+ return jsonResult({ projects: data.projects, request_id: requestId });
95
+ }
96
+ catch (err) {
97
+ return apiErrorResult(err);
98
+ }
99
+ });
100
+ // 2. list_articles
101
+ server.registerTool('list_articles', {
102
+ title: 'List articles',
103
+ description: 'List generated articles, newest first. Filter by project and status. Returns articles plus next_cursor for pagination (pass it back as cursor on a follow-up call; null means end of list).',
104
+ inputSchema: {
105
+ project_id: z
106
+ .string()
107
+ .uuid()
108
+ .optional()
109
+ .describe('Filter to one project (UUID from list_projects).'),
110
+ status: z.string().optional().describe('Filter by article status (e.g. draft, published).'),
111
+ limit: z
112
+ .number()
113
+ .int()
114
+ .min(1)
115
+ .max(100)
116
+ .optional()
117
+ .describe('Page size, 1-100. Default 20.'),
118
+ cursor: z
119
+ .string()
120
+ .optional()
121
+ .describe('Pagination cursor: the next_cursor value from the previous page.'),
122
+ },
123
+ }, async (args) => {
124
+ const client = getClient();
125
+ if (!client)
126
+ return missingKeyResult();
127
+ try {
128
+ const { data, requestId } = await client.get('/articles', {
129
+ project_id: args.project_id,
130
+ status: args.status,
131
+ limit: args.limit,
132
+ cursor: args.cursor,
133
+ });
134
+ return jsonResult({
135
+ articles: data.articles,
136
+ next_cursor: data.next_cursor,
137
+ request_id: requestId,
138
+ });
139
+ }
140
+ catch (err) {
141
+ return apiErrorResult(err);
142
+ }
143
+ });
144
+ // 3. get_article
145
+ server.registerTool('get_article', {
146
+ title: 'Get an article',
147
+ description: 'Fetch one article by id, including the full content: content_markdown, content_html, meta_description, image_url and tags, on top of the summary fields list_articles returns.',
148
+ inputSchema: {
149
+ article_id: z
150
+ .string()
151
+ .uuid()
152
+ .describe('Article UUID from list_articles or generate_article.'),
153
+ },
154
+ }, async (args) => {
155
+ const client = getClient();
156
+ if (!client)
157
+ return missingKeyResult();
158
+ try {
159
+ const { data, requestId } = await client.get(`/articles/${args.article_id}`);
160
+ return jsonResult({ article: data.article, request_id: requestId });
161
+ }
162
+ catch (err) {
163
+ return apiErrorResult(err);
164
+ }
165
+ });
166
+ // 4. generate_article
167
+ server.registerTool('generate_article', {
168
+ title: 'Generate an article',
169
+ description: 'Queue a fact-checked SEO article for a keyword and wait for it to finish (typically several minutes; this call polls up to 20 minutes). Cap: 1 article per project per day. On success the result includes article_id; use get_article to read the content and publish_article to push it to the connected CMS.',
170
+ inputSchema: {
171
+ project_id: z.string().uuid().describe('Project UUID from list_projects.'),
172
+ keyword: z
173
+ .string()
174
+ .min(2)
175
+ .max(120)
176
+ .describe('Target keyword or topic for the article (2-120 chars).'),
177
+ guide: z
178
+ .string()
179
+ .max(200)
180
+ .optional()
181
+ .describe('Optional short angle/guide for the article (max 200 chars).'),
182
+ custom_instructions: z
183
+ .string()
184
+ .max(500)
185
+ .optional()
186
+ .describe('Optional extra instructions for the writer (max 500 chars).'),
187
+ },
188
+ }, async (args, extra) => {
189
+ const client = getClient();
190
+ if (!client)
191
+ return missingKeyResult();
192
+ const notify = progressNotifier(extra, 'generate_article');
193
+ try {
194
+ const { data } = await client.post('/agents/generate', {
195
+ project_id: args.project_id,
196
+ keyword: args.keyword,
197
+ ...(args.guide ? { guide: args.guide } : {}),
198
+ ...(args.custom_instructions ? { custom_instructions: args.custom_instructions } : {}),
199
+ });
200
+ await notify?.('queued, polling for completion');
201
+ const result = await pollJob(client, data.job_id, {
202
+ timeoutMs: GENERATE_TIMEOUT_MS,
203
+ onProgress: notify,
204
+ });
205
+ if (result.timedOut || !result.job || !isTerminal(result.job.status)) {
206
+ return jsonResult(timedOutPayload(data.job_id, data.poll_url, result.job, 'article generation'));
207
+ }
208
+ if (result.job.status !== 'succeeded') {
209
+ return jsonResult({ job: result.job }, true);
210
+ }
211
+ return jsonResult({
212
+ job: result.job,
213
+ next_steps: 'Article generated. Use get_article with the article_id above to read the full content, and publish_article to push it to the connected CMS.',
214
+ });
215
+ }
216
+ catch (err) {
217
+ return apiErrorResult(err);
218
+ }
219
+ });
220
+ // 5. keyword_research
221
+ server.registerTool('keyword_research', {
222
+ title: 'Run keyword research',
223
+ description: 'Run the full keyword research pipeline for a project (live keyword data, clustering, article planning) and wait for it to finish (this call polls up to 12 minutes). Cap: 10 runs per day. The project must have a domain set.',
224
+ inputSchema: {
225
+ project_id: z.string().uuid().describe('Project UUID from list_projects.'),
226
+ },
227
+ }, async (args, extra) => {
228
+ const client = getClient();
229
+ if (!client)
230
+ return missingKeyResult();
231
+ const notify = progressNotifier(extra, 'keyword_research');
232
+ try {
233
+ const { data } = await client.post('/agents/keyword-research', { project_id: args.project_id });
234
+ // 202 `finding_more`: the project's keywords are kept topped up automatically and
235
+ // more are already being found. No job was started, so there is nothing to poll.
236
+ if (!data.job_id || !data.poll_url) {
237
+ return jsonResult({
238
+ status: data.status,
239
+ message: data.message ??
240
+ 'More keywords are being found for this project now. They appear in its plan shortly.',
241
+ });
242
+ }
243
+ await notify?.('queued, polling for completion');
244
+ const result = await pollJob(client, data.job_id, {
245
+ timeoutMs: KEYWORD_RESEARCH_TIMEOUT_MS,
246
+ onProgress: notify,
247
+ });
248
+ if (result.timedOut || !result.job || !isTerminal(result.job.status)) {
249
+ return jsonResult(timedOutPayload(data.job_id, data.poll_url, result.job, 'keyword research run'));
250
+ }
251
+ if (result.job.status !== 'succeeded') {
252
+ return jsonResult({ job: result.job }, true);
253
+ }
254
+ return jsonResult({ job: result.job, keywords_requested: data.keywords_requested });
255
+ }
256
+ catch (err) {
257
+ return apiErrorResult(err);
258
+ }
259
+ });
260
+ // 6. run_audit
261
+ server.registerTool('run_audit', {
262
+ title: 'Run an SEO audit',
263
+ description: 'Run a deep SEO audit on any domain (crawl, on-page parsing, ranking data, AI-content scoring, strategic findings) and wait for it to finish (this call polls up to 12 minutes). Cap: 5 audits per day. The result includes a shareable report_url.',
264
+ inputSchema: {
265
+ domain: z
266
+ .string()
267
+ .min(4)
268
+ .max(253)
269
+ .describe('Bare domain to audit, e.g. example.com (no protocol).'),
270
+ },
271
+ }, async (args, extra) => {
272
+ const client = getClient();
273
+ if (!client)
274
+ return missingKeyResult();
275
+ const notify = progressNotifier(extra, 'run_audit');
276
+ let jobId;
277
+ let pollUrl;
278
+ let reportUrl;
279
+ try {
280
+ const { data } = await client.post('/agents/audit', { domain: args.domain });
281
+ jobId = data.job_id;
282
+ pollUrl = data.poll_url;
283
+ reportUrl = data.report_url;
284
+ }
285
+ catch (err) {
286
+ // An audit for this domain is already running: poll the existing job instead of failing.
287
+ if (err instanceof ApiError &&
288
+ err.code === 'audit_already_running' &&
289
+ typeof err.extras['job_id'] === 'string') {
290
+ jobId = err.extras['job_id'];
291
+ pollUrl =
292
+ typeof err.extras['poll_url'] === 'string'
293
+ ? err.extras['poll_url']
294
+ : undefined;
295
+ await notify?.('audit already running for this domain, attaching to the existing job');
296
+ }
297
+ else {
298
+ return apiErrorResult(err);
299
+ }
300
+ }
301
+ try {
302
+ const result = await pollJob(client, jobId, {
303
+ timeoutMs: AUDIT_TIMEOUT_MS,
304
+ onProgress: notify,
305
+ });
306
+ if (result.timedOut || !result.job || !isTerminal(result.job.status)) {
307
+ return jsonResult(timedOutPayload(jobId, pollUrl, result.job, 'audit'));
308
+ }
309
+ if (result.job.status !== 'succeeded') {
310
+ return jsonResult({ job: result.job }, true);
311
+ }
312
+ const finalReportUrl = (typeof result.job.report_url === 'string' && result.job.report_url) || reportUrl || null;
313
+ return jsonResult({
314
+ report_url: finalReportUrl,
315
+ note: finalReportUrl ? `Full audit report: ${finalReportUrl}` : undefined,
316
+ job: result.job,
317
+ });
318
+ }
319
+ catch (err) {
320
+ return apiErrorResult(err);
321
+ }
322
+ });
323
+ // 7. publish_article
324
+ server.registerTool('publish_article', {
325
+ title: 'Publish an article',
326
+ description: "Publish a generated article to the project's connected CMS (WordPress, Webflow, Shopify, Wix, Ghost, or webhook). Synchronous: returns the dispatch result directly.",
327
+ inputSchema: {
328
+ article_id: z
329
+ .string()
330
+ .uuid()
331
+ .describe('Article UUID from list_articles or generate_article.'),
332
+ },
333
+ }, async (args) => {
334
+ const client = getClient();
335
+ if (!client)
336
+ return missingKeyResult();
337
+ try {
338
+ const { data, requestId } = await client.post('/agents/publish', {
339
+ article_id: args.article_id,
340
+ });
341
+ return jsonResult({ dispatch: data.dispatch, request_id: requestId });
342
+ }
343
+ catch (err) {
344
+ return apiErrorResult(err);
345
+ }
346
+ });
347
+ }
package/package.json CHANGED
@@ -1,6 +1,64 @@
1
1
  {
2
2
  "name": "theseoagent-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "mcpName": "io.github.jeremy665/theseoagent-mcp",
5
+ "description": "MCP server for The SEO Agent: keyword research, SEO audits, article generation and CMS publishing as native tool calls.",
6
+ "license": "MIT",
7
+ "homepage": "https://www.theseoagent.ai/connect/mcp",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/jeremy665/theseoagent-mcp.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/jeremy665/theseoagent-mcp/issues"
14
+ },
15
+ "author": {
16
+ "name": "The SEO Agent",
17
+ "email": "jeremy@theseoagent.ai"
18
+ },
19
+ "type": "module",
20
+ "bin": {
21
+ "theseoagent-mcp": "dist/index.js"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE",
27
+ "CHANGELOG.md"
28
+ ],
29
+ "engines": {
30
+ "node": ">=18"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "keywords": [
36
+ "mcp",
37
+ "mcp-server",
38
+ "model-context-protocol",
39
+ "seo",
40
+ "seo-mcp",
41
+ "seo-api",
42
+ "keyword-research",
43
+ "seo-audit",
44
+ "autoblogging",
45
+ "claude",
46
+ "cursor",
47
+ "theseoagent"
48
+ ],
49
+ "scripts": {
50
+ "build": "tsc -p tsconfig.json",
51
+ "typecheck": "tsc -p tsconfig.json --noEmit",
52
+ "smoke": "node scripts/smoke.mjs",
53
+ "prepublishOnly": "npm run build",
54
+ "clean": "node -e \"for (const d of ['dist', '.turbo']) require('node:fs').rmSync(d, { recursive: true, force: true })\""
55
+ },
56
+ "dependencies": {
57
+ "@modelcontextprotocol/sdk": "^1.29.0",
58
+ "zod": "^3.25.1"
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "^22",
62
+ "typescript": "^5.7.2"
63
+ }
64
+ }