Просмотр исходного кода

fix: 修复 Admin MCP 工具 API 路径错误

- 修正 platform 路径: /api/v1/platforms/ → /api/v1/platform/
- 修正 channel 路径: /api/v1/channels/ → /api/v1/channel/
- 修正 order 路径: /api/v1/orders/ → /api/v1/order/
- 修正 salary 路径: /api/v1/salaries/ → /api/v1/salary/

后端 API 使用单数形式,MCP 工具之前错误使用了复数形式,
导致 CREATE/UPDATE/DELETE 操作返回 404 错误。

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 3 недель назад
Родитель
Сommit
a961bdf6b2

+ 5 - 5
packages/admin-mcp-server/src/tools/channel-tools.ts

@@ -76,7 +76,7 @@ export const channelListTool = async (args: ChannelListInput) => {
     };
     };
 
 
     // Custom route uses getAllChannels endpoint
     // Custom route uses getAllChannels endpoint
-    const response = await apiClient.get<{ data: Channel[]; total: number }>('/api/v1/channels/getAllChannels', params);
+    const response = await apiClient.get<{ data: Channel[]; total: number }>('/api/v1/channel/getAllChannels', params);
 
 
     const channels = response.data || [];
     const channels = response.data || [];
     const total = response.total || 0;
     const total = response.total || 0;
@@ -138,7 +138,7 @@ export const channelGetTool = async (args: ChannelGetInput) => {
 
 
   try {
   try {
     const { id } = args;
     const { id } = args;
-    const response = await apiClient.get<Channel>('/api/v1/channels/getChannel', { id });
+    const response = await apiClient.get<Channel>('/api/v1/channel/getChannel', { id });
 
 
     const channel = response;
     const channel = response;
 
 
@@ -177,7 +177,7 @@ export const channelCreateTool = async (args: ChannelCreateInput) => {
   const apiClient = getApiClient();
   const apiClient = getApiClient();
 
 
   try {
   try {
-    const response = await apiClient.post<Channel>('/api/v1/channels/createChannel', args);
+    const response = await apiClient.post<Channel>('/api/v1/channel/createChannel', args);
 
 
     const channel = response;
     const channel = response;
 
 
@@ -217,7 +217,7 @@ export const channelUpdateTool = async (args: ChannelUpdateInput) => {
   try {
   try {
     const { id, ...updateData } = args;
     const { id, ...updateData } = args;
     // Custom route uses POST with id in body
     // Custom route uses POST with id in body
-    const response = await apiClient.post<Channel>('/api/v1/channels/updateChannel', { id, ...updateData });
+    const response = await apiClient.post<Channel>('/api/v1/channel/updateChannel', { id, ...updateData });
 
 
     const channel = response;
     const channel = response;
 
 
@@ -257,7 +257,7 @@ export const channelDeleteTool = async (args: ChannelDeleteInput) => {
   try {
   try {
     const { id } = args;
     const { id } = args;
     // Custom route uses POST with id in body
     // Custom route uses POST with id in body
-    await apiClient.post<{ success: boolean }>('/api/v1/channels/deleteChannel', { id });
+    await apiClient.post<{ success: boolean }>('/api/v1/channel/deleteChannel', { id });
 
 
     const markdown = `✅ **Channel Deleted Successfully**\n\nChannel ID ${id} has been deleted.`;
     const markdown = `✅ **Channel Deleted Successfully**\n\nChannel ID ${id} has been deleted.`;
 
 

+ 5 - 5
packages/admin-mcp-server/src/tools/order-tools.ts

@@ -91,7 +91,7 @@ export const orderListTool = async (args: OrderListInput) => {
     if (sortOrder) params.sortOrder = sortOrder;
     if (sortOrder) params.sortOrder = sortOrder;
     if (filters) params.filters = filters;
     if (filters) params.filters = filters;
 
 
-    const response = await apiClient.get<PaginatedResponse<Order>>('/api/v1/orders', params);
+    const response = await apiClient.get<PaginatedResponse<Order>>('/api/v1/order', params);
 
 
     const orders = response.data || [];
     const orders = response.data || [];
     const total = response.pagination?.total || 0;
     const total = response.pagination?.total || 0;
@@ -145,7 +145,7 @@ export const orderGetTool = async (args: OrderGetInput) => {
 
 
   try {
   try {
     const { id } = args;
     const { id } = args;
-    const response = await apiClient.get<Order>(`/api/orders/${id}`);
+    const response = await apiClient.get<Order>(`/api/v1/order/${id}`);
 
 
     const order = response;
     const order = response;
 
 
@@ -186,7 +186,7 @@ export const orderCreateTool = async (args: OrderCreateInput) => {
   const apiClient = getApiClient();
   const apiClient = getApiClient();
 
 
   try {
   try {
-    const response = await apiClient.post<Order>('/api/v1/orders/createOrder', args);
+    const response = await apiClient.post<Order>('/api/v1/order/createOrder', args);
 
 
     const order = response;
     const order = response;
 
 
@@ -225,7 +225,7 @@ export const orderUpdateTool = async (args: OrderUpdateInput) => {
 
 
   try {
   try {
     const { id, ...updateData } = args;
     const { id, ...updateData } = args;
-    const response = await apiClient.post<Order>('/api/v1/orders/updateOrder', { id, ...updateData });
+    const response = await apiClient.post<Order>('/api/v1/order/updateOrder', { id, ...updateData });
 
 
     const order = response;
     const order = response;
 
 
@@ -264,7 +264,7 @@ export const orderDeleteTool = async (args: OrderDeleteInput) => {
 
 
   try {
   try {
     const { id } = args;
     const { id } = args;
-    await apiClient.post<{ success: boolean }>('/api/v1/orders/deleteOrder', { id });
+    await apiClient.post<{ success: boolean }>('/api/v1/order/deleteOrder', { id });
 
 
     const markdown = `✅ **Order Deleted Successfully**\n\nOrder ID ${id} has been deleted.`;
     const markdown = `✅ **Order Deleted Successfully**\n\nOrder ID ${id} has been deleted.`;
 
 

+ 6 - 6
packages/admin-mcp-server/src/tools/platform-tools.ts

@@ -77,7 +77,7 @@ export const platformListTool = async (args: PlatformListInput) => {
     };
     };
 
 
     // Custom route uses getAllPlatforms endpoint
     // Custom route uses getAllPlatforms endpoint
-    const response = await apiClient.get<{ data: Platform[]; total: number }>('/api/v1/platforms/getAllPlatforms', params);
+    const response = await apiClient.get<{ data: Platform[]; total: number }>('/api/v1/platform/getAllPlatforms', params);
 
 
     const platforms = response.data || [];
     const platforms = response.data || [];
     const total = response.total || 0;
     const total = response.total || 0;
@@ -138,7 +138,7 @@ export const platformGetTool = async (args: PlatformGetInput) => {
 
 
   try {
   try {
     const { id } = args;
     const { id } = args;
-    const response = await apiClient.get<Platform>(`/api/v1/platforms/getPlatform/${id}`);
+    const response = await apiClient.get<Platform>(`/api/v1/platform/getPlatform/${id}`);
 
 
     const platform = response;
     const platform = response;
 
 
@@ -176,7 +176,7 @@ export const platformCreateTool = async (args: PlatformCreateInput) => {
   const apiClient = getApiClient();
   const apiClient = getApiClient();
 
 
   try {
   try {
-    const response = await apiClient.post<Platform>('/api/v1/platforms/createPlatform', args);
+    const response = await apiClient.post<Platform>('/api/v1/platform/createPlatform', args);
 
 
     const platform = response;
     const platform = response;
 
 
@@ -214,7 +214,7 @@ export const platformUpdateTool = async (args: PlatformUpdateInput) => {
 
 
   try {
   try {
     const { id, ...updateData } = args;
     const { id, ...updateData } = args;
-    const response = await apiClient.post<Platform>('/api/v1/platforms/updatePlatform', { id, ...updateData });
+    const response = await apiClient.post<Platform>('/api/v1/platform/updatePlatform', { id, ...updateData });
 
 
     const platform = response;
     const platform = response;
 
 
@@ -252,7 +252,7 @@ export const platformDeleteTool = async (args: PlatformDeleteInput) => {
 
 
   try {
   try {
     const { id } = args;
     const { id } = args;
-    await apiClient.post<{ success: boolean }>('/api/v1/platforms/deletePlatform', { id });
+    await apiClient.post<{ success: boolean }>('/api/v1/platform/deletePlatform', { id });
 
 
     const markdown = `✅ **Platform Deleted Successfully**\n\nPlatform ID ${id} has been deleted.`;
     const markdown = `✅ **Platform Deleted Successfully**\n\nPlatform ID ${id} has been deleted.`;
 
 
@@ -283,7 +283,7 @@ export const platformToggleStatusTool = async (args: PlatformToggleStatusInput)
 
 
   try {
   try {
     const { id } = args;
     const { id } = args;
-    const response = await apiClient.post<Platform>('/api/v1/platforms/togglePlatformStatus', { id });
+    const response = await apiClient.post<Platform>('/api/v1/platform/togglePlatformStatus', { id });
 
 
     const platform = response;
     const platform = response;
 
 

+ 5 - 5
packages/admin-mcp-server/src/tools/salary-tools.ts

@@ -78,7 +78,7 @@ export const salaryListTool = async (args: SalaryListInput) => {
     };
     };
 
 
     // Custom route uses getAllSalaries endpoint
     // Custom route uses getAllSalaries endpoint
-    const response = await apiClient.get<{ data: SalaryLevel[]; total: number }>('/api/v1/salaries/getAllSalaries', params);
+    const response = await apiClient.get<{ data: SalaryLevel[]; total: number }>('/api/v1/salary/getAllSalaries', params);
 
 
     const salaries = response.data || [];
     const salaries = response.data || [];
     const total = response.total || 0;
     const total = response.total || 0;
@@ -142,7 +142,7 @@ export const salaryGetTool = async (args: SalaryGetInput) => {
 
 
   try {
   try {
     const { id } = args;
     const { id } = args;
-    const response = await apiClient.get<SalaryLevel>(`/api/v1/salaries/${id}`);
+    const response = await apiClient.get<SalaryLevel>(`/api/v1/salary/${id}`);
 
 
     const salary = response;
     const salary = response;
 
 
@@ -182,7 +182,7 @@ export const salaryCreateTool = async (args: SalaryCreateInput) => {
   const apiClient = getApiClient();
   const apiClient = getApiClient();
 
 
   try {
   try {
-    const response = await apiClient.post<SalaryLevel>('/api/v1/salaries/createSalary', args);
+    const response = await apiClient.post<SalaryLevel>('/api/v1/salary/createSalary', args);
 
 
     const salary = response;
     const salary = response;
 
 
@@ -223,7 +223,7 @@ export const salaryUpdateTool = async (args: SalaryUpdateInput) => {
 
 
   try {
   try {
     const { id, ...updateData } = args;
     const { id, ...updateData } = args;
-    const response = await apiClient.post<SalaryLevel>('/api/v1/salaries/updateSalary', { id, ...updateData });
+    const response = await apiClient.post<SalaryLevel>('/api/v1/salary/updateSalary', { id, ...updateData });
 
 
     const salary = response;
     const salary = response;
 
 
@@ -264,7 +264,7 @@ export const salaryDeleteTool = async (args: SalaryDeleteInput) => {
 
 
   try {
   try {
     const { id } = args;
     const { id } = args;
-    await apiClient.post<{ success: boolean }>('/api/v1/salaries/deleteSalary', { id });
+    await apiClient.post<{ success: boolean }>('/api/v1/salary/deleteSalary', { id });
 
 
     const markdown = `✅ **Salary Level Deleted Successfully**\n\nSalary Level ID ${id} has been deleted.`;
     const markdown = `✅ **Salary Level Deleted Successfully**\n\nSalary Level ID ${id} has been deleted.`;