@xiedada/nodemw-mcp-server 0.2.1 → 0.2.3
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/dist/index.js +32 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,11 +33,12 @@ import { parseArgs } from "util";
|
|
|
33
33
|
|
|
34
34
|
// src/server.ts
|
|
35
35
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
36
|
+
import { createRequire } from "module";
|
|
36
37
|
|
|
37
38
|
// package.json
|
|
38
39
|
var package_default = {
|
|
39
40
|
name: "@xiedada/nodemw-mcp-server",
|
|
40
|
-
version: "0.2.
|
|
41
|
+
version: "0.2.3",
|
|
41
42
|
description: "MCP server for nodemw - MediaWiki API client",
|
|
42
43
|
repository: {
|
|
43
44
|
type: "git",
|
|
@@ -92,7 +93,10 @@ var package_default = {
|
|
|
92
93
|
};
|
|
93
94
|
|
|
94
95
|
// src/server.ts
|
|
95
|
-
|
|
96
|
+
import nodemwPkg from "nodemw/package.json";
|
|
97
|
+
var require2 = createRequire(import.meta.url);
|
|
98
|
+
var sdkVersion = require2("@modelcontextprotocol/sdk/package.json").version;
|
|
99
|
+
var DEFAULT_USER_AGENT = `nodemw/${nodemwPkg.version} (node.js ${process.version}; ${process.platform} ${process.arch}) nodemw-mcp/${package_default.version} (${package_default.name}@${package_default.version}; @modelcontextprotocol/sdk@${sdkVersion})`;
|
|
96
100
|
function createServer(description) {
|
|
97
101
|
return new McpServer(
|
|
98
102
|
{
|
|
@@ -126,6 +130,7 @@ function createBotFromConfig(config) {
|
|
|
126
130
|
port,
|
|
127
131
|
proxy,
|
|
128
132
|
userAgent,
|
|
133
|
+
userAgentAppend,
|
|
129
134
|
concurrency,
|
|
130
135
|
debug,
|
|
131
136
|
username,
|
|
@@ -133,13 +138,21 @@ function createBotFromConfig(config) {
|
|
|
133
138
|
domain,
|
|
134
139
|
dryRun
|
|
135
140
|
} = config;
|
|
141
|
+
let resolvedUA;
|
|
142
|
+
if (userAgent && userAgentAppend) {
|
|
143
|
+
resolvedUA = DEFAULT_USER_AGENT + " " + userAgent;
|
|
144
|
+
} else if (userAgent) {
|
|
145
|
+
resolvedUA = userAgent;
|
|
146
|
+
} else {
|
|
147
|
+
resolvedUA = DEFAULT_USER_AGENT;
|
|
148
|
+
}
|
|
136
149
|
return new Bot({
|
|
137
150
|
server,
|
|
138
151
|
protocol: protocol || "https",
|
|
139
152
|
port,
|
|
140
153
|
path,
|
|
141
154
|
proxy,
|
|
142
|
-
userAgent:
|
|
155
|
+
userAgent: resolvedUA,
|
|
143
156
|
concurrency,
|
|
144
157
|
debug,
|
|
145
158
|
username: username || void 0,
|
|
@@ -2983,7 +2996,9 @@ function parseCliArgs() {
|
|
|
2983
2996
|
pass: { type: "string", short: "p" },
|
|
2984
2997
|
token: { type: "string" },
|
|
2985
2998
|
debug: { type: "boolean" },
|
|
2986
|
-
"dry-run": { type: "boolean" }
|
|
2999
|
+
"dry-run": { type: "boolean" },
|
|
3000
|
+
"user-agent": { type: "string", short: "A" },
|
|
3001
|
+
"user-agent-append": { type: "boolean" }
|
|
2987
3002
|
},
|
|
2988
3003
|
strict: false,
|
|
2989
3004
|
allowPositionals: true
|
|
@@ -3023,6 +3038,8 @@ function parseCliArgs() {
|
|
|
3023
3038
|
password: values.pass ?? process.env.NODEMW_MCP_MW_PASS,
|
|
3024
3039
|
token: values.token,
|
|
3025
3040
|
dryRun: values["dry-run"],
|
|
3041
|
+
userAgent: values["user-agent"] ?? process.env.NODEMW_MCP_USER_AGENT,
|
|
3042
|
+
userAgentAppend: !!values["user-agent-append"] || process.env.NODEMW_MCP_USER_AGENT_APPEND === "1",
|
|
3026
3043
|
debug
|
|
3027
3044
|
},
|
|
3028
3045
|
pathExplicit,
|
|
@@ -3203,6 +3220,17 @@ async function main() {
|
|
|
3203
3220
|
const description = descriptionParts.join("\n");
|
|
3204
3221
|
const server = createServer(description);
|
|
3205
3222
|
registerAllTools(server, auth);
|
|
3223
|
+
server.prompt(
|
|
3224
|
+
"operating-principles",
|
|
3225
|
+
"Read these rules before using any write tools on this wiki. Call this prompt when connecting for the first time if the server instructions were not auto-injected.",
|
|
3226
|
+
{},
|
|
3227
|
+
async () => ({
|
|
3228
|
+
messages: [{
|
|
3229
|
+
role: "user",
|
|
3230
|
+
content: { type: "text", text: "Read and follow these rules:\n\n" + description }
|
|
3231
|
+
}]
|
|
3232
|
+
})
|
|
3233
|
+
);
|
|
3206
3234
|
const transport = new StdioServerTransport();
|
|
3207
3235
|
await server.connect(transport);
|
|
3208
3236
|
const authStr = auth ? `authenticated as ${config.username}` : "guest (read-only)";
|