@nqminds/mcp-client 1.0.26 → 1.0.28

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.
@@ -1 +1 @@
1
- {"version":3,"file":"MCPChat.d.ts","sourceRoot":"","sources":["../src/MCPChat.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAGxE,OAAO,KAAK,EAAyB,YAAY,EAAe,MAAM,SAAS,CAAC;AA+ChF,wBAAgB,OAAO,CAAC,EACtB,aAAa,EACb,WAA6B,EAC7B,YAAiB,EACjB,SAAc,GACf,EAAE,YAAY,qBA+gBd"}
1
+ {"version":3,"file":"MCPChat.d.ts","sourceRoot":"","sources":["../src/MCPChat.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAGxE,OAAO,KAAK,EAAyB,YAAY,EAAe,MAAM,SAAS,CAAC;AA0MhF,wBAAgB,OAAO,CAAC,EACtB,aAAa,EACb,WAA6B,EAC7B,YAAiB,EACjB,SAAc,GACf,EAAE,YAAY,qBAshBd"}
package/dist/MCPChat.js CHANGED
@@ -2,36 +2,189 @@
2
2
  import React, { useState, useRef, useEffect, useCallback } from "react";
3
3
  import ReactMarkdown from "react-markdown";
4
4
  import remarkGfm from "remark-gfm";
5
+ /**
6
+ * Strips utm_source=openai (and any surrounding & or ?) from a URL.
7
+ */
8
+ function stripUtmSource(url) {
9
+ return url
10
+ .replace(/[?&]utm_source=openai/gi, (match) => (match.startsWith("?") ? "?" : ""))
11
+ .replace(/\?$/, "");
12
+ }
13
+ /**
14
+ * Post-processes AI response content to ensure all links open in a new tab
15
+ * and have tracking parameters removed.
16
+ * Converts HTML anchor tags (<a href="...">) into markdown links ([text](url))
17
+ * so they are handled by the ReactMarkdown custom 'a' component which adds
18
+ * target="_blank" rel="noopener noreferrer". This also prevents raw HTML
19
+ * anchor tags from breaking markdown tables.
20
+ */
21
+ function preprocessLinks(content) {
22
+ // Convert HTML anchors to markdown links (stripping utm params)
23
+ const step1 = content.replace(/<a\s[^>]*?href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi, (_, href, innerHtml) => {
24
+ const linkText = innerHtml.replace(/<[^>]+>/g, "").trim();
25
+ return `[${linkText || href}](${stripUtmSource(href)})`;
26
+ });
27
+ // Strip utm params from plain markdown links [text](url)
28
+ return step1.replace(/\[([^\]]*)\]\(([^)]*)\)/g, (_, text, url) => `[${text}](${stripUtmSource(url)})`);
29
+ }
5
30
  const DEFAULT_ACTIONS = [
6
31
  {
7
32
  label: "Company overview",
8
33
  icon: "🏢",
9
- prompt: "Please provide a comprehensive company overview. Include key business information, company structure, size, registered details, and any notable financial highlights.",
34
+ prompt: `You are an expert business and investment analyst and your aim is to provide a clear and comprehensive overview of the company.
35
+
36
+ This information should include:
37
+
38
+ - What the company does: products, services, and the problem it solves
39
+ - Basic facts: name, founding date, headquarters, ownership, size, and locations
40
+ - History: key milestones, mergers, launches, and growth
41
+ - Business model: how it makes money and who its customers are
42
+ - Market position: industry, competitors, market share, and differentiators
43
+ - Financial picture: revenue, profit, funding, valuation, or other key metrics
44
+ - Leadership and governance: executives, board, and organisational structure
45
+ - Operations: major business units, supply chain, technology, and partnerships
46
+ - Strategy: goals, expansion plans, innovation, and risks
47
+ - Culture and people: workforce, values, hiring, and reputation
48
+ - Legal and regulatory matters: compliance, litigation, and major constraints
49
+ - ESG or public impact: sustainability, ethics, and social responsibility
50
+ - Recent developments: major news, acquisitions, product releases, or leadership changes
51
+
52
+ Use formal and impersonal language and avoid referring to these instructions. Format your output using markdown.`,
10
53
  },
11
54
  {
12
55
  label: "Competitor analysis",
13
56
  icon: "⚔️",
14
- prompt: "Please perform a competitor analysis. Identify the main competitors in this sector, assess market positioning, and highlight competitive advantages or disadvantages.",
57
+ prompt: `You are an expert business analyst. Your aim is to analyse the competitive environment of the company.
58
+
59
+ 1. Find the website for the company
60
+ 2. Determine the sector(s) in which it operates and its value proposition(s)
61
+ 3. For each combination of sector and value proposition:
62
+ 3.1. Perform one or more searches to find competitors
63
+ 3.1.1. Competitors operate in the same sector and have similar value propositions
64
+ 3.2. For each competitor:
65
+ 3.2.1. Record the URL to their website
66
+ 3.2.2. Create a brief description of their business
67
+ 3.2.3. Say why you consider them to be a competitor
68
+
69
+ Use formal and impersonal language and avoid referring to these instructions. Format your output using markdown.`,
15
70
  },
16
71
  {
17
72
  label: "Risk analysis",
18
73
  icon: "⚠️",
19
- prompt: "Please perform a thorough risk analysis. Identify key business risks, financial risks, operational risks, and any concerning patterns in the data.",
74
+ prompt: `You are an expert business analyst. Your aim is to analyse the company for risks. Here are some ideas - do what you think is relevant and do as much due diligence as you can.
75
+
76
+ 1. Browse the company's filing history, which can be found here:
77
+ https://find-and-update.company-information.service.gov.uk/company/[companies_house_number]/filing-history
78
+ 1.1. Inspect the filing history for anything that might indicate a risk, e.g. late filings, gazette notices, name changes, changes in shareholdings, etc. These are just examples; use your initiative and expertise to identify other indicators of risk
79
+ 2. Create a list of the directors, persons of significant control (PSC, in the UK Companies House sense) and investors for the company. Note that directors, PSCs and investors might be people or other companies
80
+ 2.1 For each director, PSC and investor:
81
+ 2.1.1. Perform multiple searches on the internet and try to collect the following information:
82
+ 2.1.1.1. Create a brief professional history of the person
83
+ 2.1.2.3. Identify other activities, such as memberships of profession bodies or standards organisations
84
+ 2.1.2.4. Is the person associated with dissolved businesses or have all of their previous ventures been successful?
85
+ 2.1.2.5. Has the person ever changed their name?
86
+ 2.1.2.6. Do they frequently change their address?
87
+ 2.1.2.7. Are there any FCA (Financial Conduct Authority) or other regulatory actions against them or businesses they have been involved in?
88
+ 2.1.3. You must also find any other potentially conflicting interests:
89
+ 2.1.3.1. Are they a director of any other company, or have they been in the past?
90
+ 2.1.3.2. Are they a PSC of any other company, or have they been in the past?
91
+ 2.1.3.3. Are they an investor in any other company, or have they been in the past?
92
+ 2.1.3.4. Are they associated with any dissolved or dormant companies?
93
+ 2.1.3.5. Do they perform any other paid or unpaid work?
94
+ 2.1.3.6. Are there any potential conflicts of interest? Are they involved in any related parties?
95
+ 2.1.3.7. Have there been any potential conflicts of interest in the past?
96
+ 2.1.3.8. Are they a director, PSC or investor of one of the other directors, PSCs or investors of the company?
97
+ 2.1.3.9. Are there possible family relationships between directors, PSCs or investors?
98
+ 3. Check whether dissolved entities registered at the same address share directors, PSCs or investors with the company
99
+ 4. Your response should include a clear summary of each risk factor identified, with a rating from low to high and a suggestion for further investigation.
100
+
101
+ Note that your database does not list dissolved companies so you will need to search for those on Companies House. To gather additional information on people, use Companies House people search. The same person might appear in the search results multiple times with the same name so reconcile on birth date or address.
102
+
103
+ You MUST check the reason for a dissolution if you discover a relevant dissolved company.
104
+
105
+ Use formal and impersonal language and avoid referring to these instructions.
106
+ Format your output using markdown.`,
20
107
  },
21
108
  {
22
109
  label: "Online sentiment",
23
110
  icon: "🌐",
24
- prompt: "Please assess the online sentiment and public perception. Look for relevant news coverage, reviews, reputational issues, and overall public standing.",
111
+ prompt: `You are an expert business analyst and your aim is to estimate sentiment about the company and its products or services online and to determine trends.
112
+
113
+ 1. Find the website for the company
114
+ 2. Create a list of its product and service offerings
115
+ 3. For the company itself and each of its product or service offerings:
116
+ 3.1. Perform one or more searches in each of the time ranges:
117
+ 3.1.1. Five years ago to one year ago
118
+ 3.1.2. One year ago to today
119
+ 3.2. Determine whether there is enough information to estimate sentiment trends
120
+ 3.2.1. Strong evidence of positive sentiment includes
121
+ 3.2.1.1. Evidence of commercial sales and revenue earning contracts
122
+ 3.2.1.2. Positive customer reviews
123
+ 3.2.1.3. Revenue related partnerships with large organisations
124
+ 3.2.2. Weak evidence of positive sentiment includes
125
+ 3.2.2.1. Sales and marketing material
126
+ 3.2.2.2. Company announcements of new products
127
+ 3.2.2.3. Non-commercial funding, such as government grants, R&D funding
128
+ 3.2.2.4. Presence on procurement frameworks without evidence of sales
129
+ 3.2.2.5. Pilots, test deployments, non-paying case studies
130
+ 3.3. If there is enough information:
131
+ 3.3.1. Describe the sentiment for the company and each product or service
132
+ 3.3.1.1. Sentiment should be bad, poor, neutral, good, excellent, with evidence described as weak or strong
133
+ 3.3.2. Identify the change in sentiment from the company and each product or service
134
+ 3.3.2.1. Change in sentiment should be deteriorating, stable or improving
135
+ 3.3.3. Highlight key events that evidence sentiment and the identified changes
136
+
137
+ Use formal and impersonal language and avoid referring to these instructions.
138
+ Format your output using markdown.`,
25
139
  },
26
140
  {
27
141
  label: "SWOT analysis",
28
142
  icon: "📊",
29
- prompt: "Please perform a full SWOT analysis. Cover Strengths, Weaknesses, Opportunities, and Threats in detail.",
143
+ prompt: `You are an expert business analyst. Your aim is to analyse the company and its competitive environment in detail and perform a SWOT analysis.
144
+
145
+ 1. Use your tool and Companies House to gather detailed information about the company
146
+ 1.1. Consider its finances, structure, governance and senior personnel
147
+ 2. Find the website for the company
148
+ 2.1 Determine the sector(s) in which it operates and its value proposition(s)
149
+ 2.2. For each combination of sector and value proposition:
150
+ 2.2.1. Perform one or more searches to find competitors
151
+ 2.2.1.1. Competitors operate in the same sector and have similar value propositions
152
+ 2.2.1. For each competitor:
153
+ 2.2.1.1. Gather information you need to perform your SWOT analysis
154
+ 3. Using the information gathered, perform a detailed SWOT analysis
155
+
156
+ Use formal and impersonal language and avoid referring to these instructions.
157
+ Format your output using markdown.`,
30
158
  },
31
159
  {
32
160
  label: "Research key people",
33
161
  icon: "👤",
34
- prompt: "Please research the key people associated with this company. Include directors, persons of significant control, major shareholders, and relevant background information.",
162
+ prompt: `You are an expert investment analyst and your task is to perform detailed due diligence on the most senior people that are involved in the company. Don't ask for clarification - go ahead and do the work now.
163
+
164
+ 1. Create a list of the directors, persons of significant control and other senior people at the company.
165
+ 2. For each person:
166
+ 2.1. Perform multiple searches on the internet and extract enough information for the requirements below
167
+ 2.1.1. Be very careful to make sure that you do not confuse different people with the same name.
168
+ 2.1.1.1. Two webpages that refer to the same name might be referring to different people unless they both mention the same fact about the named person, e.g. website A says Michael Pernell runs a cybersecurity business and his hobby is knitting and website B says that Michael Pernell likes knitting and is an entrepreneur - they're likely to be the same person.
169
+ 2.1.2. Perform enough searches to create
170
+ 2.1.2.1. An educational history of the person
171
+ 2.1.2.2. A professional history of the person
172
+ 2.1.2.3. Other activities, such as memberships of profession bodies or standards organisations
173
+ 2.1.2.4. Is the person closely associated with any other people, e.g. repeatedly forms companies with particular people
174
+ 2.1.2.5. Estimate whether the person's history indicates business success or failure
175
+ 2.1.2.6. Try to detect name changes, address changes or other unusual activity
176
+ 2.1.2.7. Try to find regulatory actions against the individual, such as CCJ, FCA rulings, strike-offs, employment tribunal actions, etc.
177
+ 2.1.3. You must also find any other business interests of the person:
178
+ 2.1.3.1. Is the person a director of any other company, or have they been in the past?
179
+ 2.1.3.2. Is the person a PSC of any other company, or have they been in the past?
180
+ 2.1.3.3. Does the person have investments in any other company?
181
+ 2.1.3.4. Does the person perform any other paid or unpaid work?
182
+ 2.1.3.5. Does the person appear to have any potential conflicts of interest?
183
+ 2.1.4. Are people likely to be linked by family relationships?
184
+
185
+ Use formal and impersonal language and avoid referring to these instructions.
186
+ Format your output using markdown.
187
+ `,
35
188
  },
36
189
  ];
37
190
  export function MCPChat({ companyNumber, apiEndpoint = "/api/mcp/chat", customStyles = {}, className = "", }) {
@@ -336,7 +489,9 @@ export function MCPChat({ companyNumber, apiEndpoint = "/api/mcp/chat", customSt
336
489
  .map((msg, idx) => (React.createElement("div", { key: idx, className: `mcp-chat-message ${msg.role === "user" ? "mcp-chat-message-user" : "mcp-chat-message-assistant"}` },
337
490
  React.createElement("div", { className: "mcp-chat-message-bubble" },
338
491
  msg.role === "assistant" ? (React.createElement("div", { className: "mcp-chat-message-content markdown-content" },
339
- React.createElement(ReactMarkdown, { remarkPlugins: [remarkGfm] }, msg.content))) : (React.createElement("div", { className: "mcp-chat-message-content" }, msg.content)),
492
+ React.createElement(ReactMarkdown, { remarkPlugins: [remarkGfm], components: {
493
+ a: ({ href, children }) => (React.createElement("a", { href: href, target: "_blank", rel: "noopener noreferrer" }, children)),
494
+ } }, preprocessLinks(msg.content)))) : (React.createElement("div", { className: "mcp-chat-message-content" }, msg.content)),
340
495
  msg.role === "assistant" && !msg.isStreaming && (React.createElement("div", { className: "mcp-chat-message-timestamp" },
341
496
  msg.timestamp.toLocaleTimeString(),
342
497
  msg.tokenInfo && (React.createElement("span", { className: "mcp-chat-token-info" }, msg.tokenInfo)))))))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nqminds/mcp-client",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "Reusable MCP client component with AI chat interface",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",