Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions src/tools/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { WordPressClient } from "@/client/api.js";
import type { MCPToolSchema } from "@/types/mcp.js";
import { AuthMethod } from "@/types/client.js";
import { getErrorMessage } from "@/utils/error.js";

Expand All @@ -14,14 +15,7 @@ export class AuthTools {
public getTools(): Array<{
name: string;
description: string;
parameters?: Array<{
name: string;
type?: string;
description?: string;
required?: boolean;
enum?: string[];
items?: unknown;
}>;
inputSchema?: MCPToolSchema;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle inputSchema tools in documentation generator

After this migration, these tool classes no longer expose parameters, but the docs pipeline still reads only toolDef.parameters (for parameter extraction and example generation in src/docs/DocumentationGenerator.ts). As a result, running docs/OpenAPI generation now produces incomplete docs for migrated tools (missing parameter tables, required args, and realistic examples) even though the tools do accept those inputs via inputSchema.

Useful? React with 👍 / 👎.

handler: (client: WordPressClient, params: Record<string, unknown>) => Promise<unknown>;
}> {
return [
Expand All @@ -35,42 +29,48 @@ export class AuthTools {
"• Verify setup: Use this after configuring new credentials\n" +
"• Troubleshoot: Run when experiencing connection issues\n" +
"• Health check: Regular verification of WordPress connectivity",
parameters: [], // The 'site' parameter is added dynamically by the server
// The 'site' parameter is added dynamically by the server
inputSchema: {
type: "object",
properties: {},
Comment on lines +32 to +35
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (bug_risk): Consider aligning the wp_test_auth schema with how the dynamic site parameter is injected and validated.

With inputSchema now defined as an empty object, any dynamically injected site field may not be represented in the runtime schema. Please confirm that either (a) the effective schema at validation time includes site, or (b) this tool’s validation is configured to allow unknown properties, so callers don’t hit schema/validation mismatches compared to tools where all fields are declared.

},
handler: this.handleTestAuth.bind(this),
},
{
name: "wp_get_auth_status",
description: "Gets the current authentication status for a configured WordPress site.",
parameters: [],
inputSchema: {
type: "object",
properties: {},
},
handler: this.handleGetAuthStatus.bind(this),
},
{
name: "wp_switch_auth_method",
description: "Switches the authentication method for a site for the current session.",
parameters: [
{
name: "method",
type: "string",
required: true,
description: "The new authentication method to use.",
enum: ["app-password", "jwt", "basic", "api-key", "cookie"],
inputSchema: {
type: "object",
properties: {
method: {
type: "string",
description: "The new authentication method to use.",
enum: ["app-password", "jwt", "basic", "api-key", "cookie"],
},
username: {
type: "string",
description: "The username for 'app-password' or 'basic' authentication.",
},
password: {
type: "string",
description: "The Application Password for 'app-password' or password for 'basic' auth.",
},
jwt_token: {
type: "string",
description: "The token for 'jwt' authentication.",
},
},
{
name: "username",
type: "string",
description: "The username for 'app-password' or 'basic' authentication.",
},
{
name: "password",
type: "string",
description: "The Application Password for 'app-password' or password for 'basic' auth.",
},
{
name: "jwt_token",
type: "string",
description: "The token for 'jwt' authentication.",
},
],
required: ["method"],
},
handler: this.handleSwitchAuthMethod.bind(this),
},
];
Expand Down
188 changes: 94 additions & 94 deletions src/tools/comments.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { WordPressClient } from "@/client/api.js";
import { MCPToolSchema } from "@/types/mcp.js";
import { CommentQueryParams, CreateCommentRequest, UpdateCommentRequest } from "@/types/wordpress.js";
import { getErrorMessage } from "@/utils/error.js";
import { toolParams } from "./params.js";
Expand All @@ -15,143 +16,142 @@ export class CommentTools {
public getTools(): Array<{
name: string;
description: string;
parameters?: Array<{
name: string;
type?: string;
description?: string;
required?: boolean;
enum?: string[];
items?: unknown;
}>;
inputSchema?: MCPToolSchema;
handler: (client: WordPressClient, params: Record<string, unknown>) => Promise<unknown>;
}> {
return [
{
name: "wp_list_comments",
description: "Lists comments from a WordPress site, with filters.",
parameters: [
{
name: "post",
type: "number",
description: "Limit results to comments assigned to a specific post ID.",
inputSchema: {
type: "object",
properties: {
post: {
type: "number",
description: "Limit results to comments assigned to a specific post ID.",
},
status: {
type: "string",
description: "Filter by comment status.",
enum: ["hold", "approve", "spam", "trash"],
},
},
{
name: "status",
type: "string",
description: "Filter by comment status.",
enum: ["hold", "approve", "spam", "trash"],
},
],
},
handler: this.handleListComments.bind(this),
},
{
name: "wp_get_comment",
description: "Retrieves a single comment by its ID.",
parameters: [
{
name: "id",
type: "number",
required: true,
description: "The unique identifier for the comment.",
inputSchema: {
type: "object",
properties: {
id: {
type: "number",
description: "The unique identifier for the comment.",
},
},
],
required: ["id"],
},
handler: this.handleGetComment.bind(this),
},
{
name: "wp_create_comment",
description: "Creates a new comment on a post.",
parameters: [
{
name: "post",
type: "number",
required: true,
description: "The ID of the post to comment on.",
},
{
name: "content",
type: "string",
required: true,
description: "The content of the comment.",
},
{
name: "author_name",
type: "string",
description: "The name of the comment author.",
},
{
name: "author_email",
type: "string",
description: "The email of the comment author.",
inputSchema: {
type: "object",
properties: {
post: {
type: "number",
description: "The ID of the post to comment on.",
},
content: {
type: "string",
description: "The content of the comment.",
},
author_name: {
type: "string",
description: "The name of the comment author.",
},
author_email: {
type: "string",
description: "The email of the comment author.",
},
},
],
required: ["post", "content"],
},
handler: this.handleCreateComment.bind(this),
},
{
name: "wp_update_comment",
description: "Updates an existing comment.",
parameters: [
{
name: "id",
type: "number",
required: true,
description: "The ID of the comment to update.",
inputSchema: {
type: "object",
properties: {
id: {
type: "number",
description: "The ID of the comment to update.",
},
content: {
type: "string",
description: "The updated content for the comment.",
},
status: {
type: "string",
description: "The new status for the comment.",
enum: ["hold", "approve", "spam", "trash"],
},
},
{
name: "content",
type: "string",
description: "The updated content for the comment.",
},
{
name: "status",
type: "string",
description: "The new status for the comment.",
enum: ["hold", "approve", "spam", "trash"],
},
],
required: ["id"],
},
handler: this.handleUpdateComment.bind(this),
},
{
name: "wp_delete_comment",
description: "Deletes a comment.",
parameters: [
{
name: "id",
type: "number",
required: true,
description: "The ID of the comment to delete.",
},
{
name: "force",
type: "boolean",
description: "If true, the comment will be permanently deleted. Defaults to false (moved to trash).",
inputSchema: {
type: "object",
properties: {
id: {
type: "number",
description: "The ID of the comment to delete.",
},
force: {
type: "boolean",
description: "If true, the comment will be permanently deleted. Defaults to false (moved to trash).",
},
},
],
required: ["id"],
},
handler: this.handleDeleteComment.bind(this),
},
{
name: "wp_approve_comment",
description: "Approves a pending comment.",
parameters: [
{
name: "id",
type: "number",
required: true,
description: "The ID of the comment to approve.",
inputSchema: {
type: "object",
properties: {
id: {
type: "number",
description: "The ID of the comment to approve.",
},
},
],
required: ["id"],
},
handler: this.handleApproveComment.bind(this),
},
{
name: "wp_spam_comment",
description: "Marks a comment as spam.",
parameters: [
{
name: "id",
type: "number",
required: true,
description: "The ID of the comment to mark as spam.",
inputSchema: {
type: "object",
properties: {
id: {
type: "number",
description: "The ID of the comment to mark as spam.",
},
},
],
required: ["id"],
},
handler: this.handleSpamComment.bind(this),
},
];
Expand Down
Loading
Loading