• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

popstas / planfix-mcp-server / 18244711899

04 Oct 2025 01:05PM UTC coverage: 80.448% (+0.2%) from 80.254%
18244711899

push

github

web-flow
Allow sell task creation without resolved contact (#55)

465 of 651 branches covered (71.43%)

Branch coverage included in aggregate %.

3238 of 3952 relevant lines covered (81.93%)

2.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.53
/src/server.ts
1
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
1✔
2
import {
1✔
3
  CallToolRequestSchema,
4
  ListToolsRequestSchema,
5
} from "@modelcontextprotocol/sdk/types.js";
6
import { log } from "./helpers.js";
1✔
7
import { ToolWithHandler } from "./types.js";
8

9
import planfix_add_to_lead_task from "./tools/planfix_add_to_lead_task.js";
1✔
10
import planfix_create_comment from "./tools/planfix_create_comment.js";
1✔
11
import planfix_create_contact from "./tools/planfix_create_contact.js";
1✔
12
import planfix_create_lead_task from "./tools/planfix_create_lead_task.js";
1✔
13
import planfix_create_sell_task from "./tools/planfix_create_sell_task.js";
1✔
14
import planfix_create_sell_task_ids from "./tools/planfix_create_sell_task_ids.js";
1✔
15
import planfix_create_task from "./tools/planfix_create_task.js";
1✔
16
import planfix_get_child_tasks from "./tools/planfix_get_child_tasks.js";
1✔
17
import planfix_get_report_fields from "./tools/planfix_get_report_fields.js";
1✔
18
import planfix_reports_list from "./tools/planfix_reports_list.js";
1✔
19
import planfix_request from "./tools/planfix_request.js";
1✔
20
import planfix_run_report from "./tools/planfix_run_report.js";
1✔
21
import planfix_search_company from "./tools/planfix_search_company.js";
1✔
22
import planfix_search_contact from "./tools/planfix_search_contact.js";
1✔
23
import planfix_search_directory from "./tools/planfix_search_directory.js";
1✔
24
import planfix_search_directory_entry from "./tools/planfix_search_directory_entry.js";
1✔
25
import planfix_search_lead_task from "./tools/planfix_search_lead_task.js";
1✔
26
import planfix_search_manager from "./tools/planfix_search_manager.js";
1✔
27
import planfix_search_project from "./tools/planfix_search_project.js";
1✔
28
import planfix_search_task from "./tools/planfix_search_task.js";
1✔
29
import planfix_update_contact from "./tools/planfix_update_contact.js";
1✔
30
import planfix_update_lead_task from "./tools/planfix_update_lead_task.js";
1✔
31

32
export const TOOLS: ToolWithHandler[] = [
1✔
33
  planfix_add_to_lead_task,
1✔
34
  planfix_create_comment,
1✔
35
  planfix_create_contact,
1✔
36
  planfix_create_lead_task,
1✔
37
  planfix_create_sell_task,
1✔
38
  planfix_create_sell_task_ids,
1✔
39
  planfix_create_task,
1✔
40
  planfix_get_child_tasks,
1✔
41
  planfix_get_report_fields,
1✔
42
  planfix_reports_list,
1✔
43
  planfix_request,
1✔
44
  planfix_run_report,
1✔
45
  planfix_search_company,
1✔
46
  planfix_search_contact,
1✔
47
  planfix_search_directory,
1✔
48
  planfix_search_directory_entry,
1✔
49
  planfix_search_lead_task,
1✔
50
  planfix_search_manager,
1✔
51
  planfix_search_project,
1✔
52
  planfix_search_task,
1✔
53
  planfix_update_contact,
1✔
54
  planfix_update_lead_task,
1✔
55
];
1✔
56

57
export function createPlanfixServer(): Server {
1✔
58
  const server = new Server(
1✔
59
    {
1✔
60
      name: "planfix-mcp-server",
1✔
61
      version: "1.0.0",
1✔
62
    },
1✔
63
    {
1✔
64
      capabilities: {
1✔
65
        tools: {},
1✔
66
      },
1✔
67
    },
1✔
68
  );
1✔
69

70
  server.setRequestHandler(ListToolsRequestSchema, async () => {
1✔
71
    return { tools: TOOLS };
1✔
72
  });
1✔
73

74
  interface AnswerContent {
75
    type: string;
76
    text: string;
77
  }
78

79
  interface AnswerJson<T = unknown> {
80
    content: AnswerContent[];
81
    structuredContent: T;
82
  }
83

84
  function getAnswerJson<T = unknown>(data: T): AnswerJson<T> {
1✔
85
    return {
1✔
86
      structuredContent: data,
1✔
87
      content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
1✔
88
    };
1✔
89
  }
1✔
90

91
  // @ts-expect-error - The SDK's type definitions are too strict for our use case
92
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
1✔
93
    const { name, arguments: args } = request.params;
1✔
94
    log(`Received tool call: ${name}`);
1✔
95
    try {
1✔
96
      const tool = TOOLS.find((t) => t.name === name);
1✔
97
      if (!tool?.handler) {
1!
98
        return getAnswerJson({ error: `Handler not found for tool: ${name}` });
×
99
      }
×
100
      return getAnswerJson(await tool.handler(args));
1✔
101
    } catch (error) {
1!
102
      console.error(`Error calling tool ${name}:`, error);
×
103
      return getAnswerJson({
×
104
        error: error instanceof Error ? error.message : "Unknown error",
×
105
      });
×
106
    }
×
107
  });
1✔
108

109
  return server;
1✔
110
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc