@mcp-z/mcp-sheets 2.3.0 → 2.3.2
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/README.md +18 -11
- package/dist/cjs/setup/config.js +5 -4
- package/dist/cjs/setup/config.js.map +1 -1
- package/dist/cjs/setup/runtime.js +3 -2
- package/dist/cjs/setup/runtime.js.map +1 -1
- package/dist/esm/setup/config.js +4 -3
- package/dist/esm/setup/config.js.map +1 -1
- package/dist/esm/setup/runtime.js +3 -2
- package/dist/esm/setup/runtime.js.map +1 -1
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
MCP server for Google Sheets integration with OAuth authentication, spreadsheet management, batch operations, and advanced formatting
|
|
4
4
|
|
|
5
|
+
Requires Node.js >=20. The examples use `npx`, included with npm, to run this server and `@mcp-z/cli`.
|
|
6
|
+
|
|
5
7
|
## Common uses
|
|
6
8
|
|
|
7
9
|
- Find spreadsheets and sheets
|
|
@@ -12,6 +14,11 @@ MCP server for Google Sheets integration with OAuth authentication, spreadsheet
|
|
|
12
14
|
|
|
13
15
|
MCP supports stdio and HTTP.
|
|
14
16
|
|
|
17
|
+
Both the 2025 and 2026-07-28 protocol revisions are served, over either transport, from the same
|
|
18
|
+
server. Your client negotiates whichever it speaks. A 2025 client keeps working with no change,
|
|
19
|
+
and support for it is not being dropped. The 2026-07-28 revision is stateless, so a client speaking
|
|
20
|
+
it sends no `initialize` handshake and carries no session id.
|
|
21
|
+
|
|
15
22
|
**Stdio**
|
|
16
23
|
```json
|
|
17
24
|
{
|
|
@@ -40,7 +47,7 @@ MCP supports stdio and HTTP.
|
|
|
40
47
|
}
|
|
41
48
|
```
|
|
42
49
|
|
|
43
|
-
`start` is an extension used by `npx @mcp-z/cli up` to launch HTTP servers for you.
|
|
50
|
+
`start` is an extension used by `npx @mcp-z/cli up` to launch HTTP servers for you. The HTTP endpoint is `/mcp`.
|
|
44
51
|
|
|
45
52
|
## Create a Google Cloud app
|
|
46
53
|
|
|
@@ -49,10 +56,10 @@ MCP supports stdio and HTTP.
|
|
|
49
56
|
3. Enable the Google Sheets API.
|
|
50
57
|
4. Create OAuth 2.0 credentials (Desktop app).
|
|
51
58
|
5. Copy the Client ID and Client Secret.
|
|
52
|
-
6. Select
|
|
53
|
-
- For stdio, choose "
|
|
54
|
-
- For
|
|
55
|
-
- For local hosting, add
|
|
59
|
+
6. Select the credential type that matches your transport:
|
|
60
|
+
- For stdio, choose "Desktop app" under APIs & Services.
|
|
61
|
+
- For HTTP, choose "Web application" and add your public `/oauth/callback` URL. Local HTTP uses the port configured with `--port` or `PORT`.
|
|
62
|
+
- For local hosting, add `http://127.0.0.1` for the [ephemeral redirect URL](https://en.wikipedia.org/wiki/Ephemeral_port).
|
|
56
63
|
7. Enable OAuth2 [scopes](https://console.cloud.google.com/auth/scopes): openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive
|
|
57
64
|
8. Add [test emails](https://console.cloud.google.com/auth/audience)
|
|
58
65
|
|
|
@@ -90,7 +97,7 @@ Example (http) - Create .mcp.json:
|
|
|
90
97
|
"mcpServers": {
|
|
91
98
|
"sheets": {
|
|
92
99
|
"type": "http",
|
|
93
|
-
"url": "http://localhost:3000",
|
|
100
|
+
"url": "http://localhost:3000/mcp",
|
|
94
101
|
"start": {
|
|
95
102
|
"command": "npx",
|
|
96
103
|
"args": ["-y", "@mcp-z/mcp-sheets", "--port=3000"],
|
|
@@ -105,7 +112,7 @@ Example (http) - Create .mcp.json:
|
|
|
105
112
|
|
|
106
113
|
Local (default): omit REDIRECT_URI → ephemeral loopback. Cloud: set REDIRECT_URI to your public /oauth/callback and expose the service publicly.
|
|
107
114
|
|
|
108
|
-
Note: start block is a helper in
|
|
115
|
+
Note: the `start` block is a helper in `npx @mcp-z/cli up` for starting an HTTP server from your `.mcp.json`. See [@mcp-z/cli](https://github.com/mcp-z/cli) for details.
|
|
109
116
|
|
|
110
117
|
### Service account
|
|
111
118
|
|
|
@@ -160,10 +167,10 @@ HTTP only. Requires a public base URL.
|
|
|
160
167
|
|
|
161
168
|
```bash
|
|
162
169
|
# List tools
|
|
163
|
-
mcp-z inspect --servers sheets --tools
|
|
170
|
+
npx -y @mcp-z/cli inspect --servers sheets --tools
|
|
164
171
|
|
|
165
172
|
# Find a spreadsheet
|
|
166
|
-
mcp-z call sheets spreadsheet-find '{"spreadsheetRef":"Quarterly Report"}'
|
|
173
|
+
npx -y @mcp-z/cli call-tool sheets spreadsheet-find '{"spreadsheetRef":"Quarterly Report"}'
|
|
167
174
|
```
|
|
168
175
|
|
|
169
176
|
## Tools
|
|
@@ -206,7 +213,7 @@ mcp-z call sheets spreadsheet-find '{"spreadsheetRef":"Quarterly Report"}'
|
|
|
206
213
|
|
|
207
214
|
## Configuration reference
|
|
208
215
|
|
|
209
|
-
See `server.json` for all supported environment variables, CLI arguments, and defaults.
|
|
216
|
+
See [`server.json`](https://github.com/mcp-z/mcp-sheets/blob/master/server.json) for all supported environment variables, CLI arguments, and defaults.
|
|
210
217
|
|
|
211
218
|
## Storage backends
|
|
212
219
|
|
|
@@ -224,6 +231,6 @@ TOKEN_STORE_URI=redis://localhost:6379 mcp-sheets
|
|
|
224
231
|
|
|
225
232
|
A protocol whose adapter is missing fails at startup naming the package to install.
|
|
226
233
|
|
|
227
|
-
|
|
234
|
+
## Documentation
|
|
228
235
|
|
|
229
236
|
[API Docs](https://mcp-z.github.io/mcp-sheets)
|
package/dist/cjs/setup/config.js
CHANGED
|
@@ -16,6 +16,7 @@ _export(exports, {
|
|
|
16
16
|
return parseConfig;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
+
var _nodeurl = require("node:url");
|
|
19
20
|
var _module = require("module");
|
|
20
21
|
var _os = require("os");
|
|
21
22
|
var _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
|
|
@@ -180,12 +181,12 @@ function normalizeResourceStoreUri(resourceStoreUri) {
|
|
|
180
181
|
var filePrefix = 'file://';
|
|
181
182
|
if (resourceStoreUri.startsWith(filePrefix)) {
|
|
182
183
|
var rawPath = resourceStoreUri.slice(filePrefix.length);
|
|
183
|
-
var
|
|
184
|
-
return
|
|
184
|
+
var filePath = rawPath.startsWith('~') ? rawPath.replace(/^~/, (0, _os.homedir)()) : rawPath.startsWith('/') ? (0, _nodeurl.fileURLToPath)(resourceStoreUri) : rawPath;
|
|
185
|
+
return (0, _nodeurl.pathToFileURL)(_path.resolve(filePath)).href;
|
|
185
186
|
}
|
|
186
187
|
if (resourceStoreUri.includes('://')) return resourceStoreUri;
|
|
187
|
-
var
|
|
188
|
-
return
|
|
188
|
+
var expandedPath = resourceStoreUri.startsWith('~') ? resourceStoreUri.replace(/^~/, (0, _os.homedir)()) : resourceStoreUri;
|
|
189
|
+
return (0, _nodeurl.pathToFileURL)(_path.resolve(expandedPath)).href;
|
|
189
190
|
}
|
|
190
191
|
function createConfig() {
|
|
191
192
|
return parseConfig(process.argv, process.env);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/setup/config.ts"],"sourcesContent":["import type * as OAuthGoogle from '@mcp-z/oauth-google';\nimport type * as McpServer from '@mcp-z/server';\nimport { Module } from 'module';\nimport { homedir } from 'os';\nimport * as path from 'path';\nimport { parseArgs } from 'util';\nimport { GOOGLE_SCOPE } from '../constants.ts';\nimport type { ServerConfig } from '../types.ts';\nimport { readPkg } from './version-help.ts';\n\nconst pkg = readPkg();\n\n// @mcp-z/oauth-google and @mcp-z/server are requireable at the >=20 floor; deferred so\n// --version/--help (handled via version-help.ts, never this file) load neither package.\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n/**\n * Parse Sheets server configuration from CLI arguments and environment.\n *\n * CLI Arguments (all optional):\n * - --auth=<mode> Authentication mode (default: loopback-oauth)\n * Modes: loopback-oauth, service-account, dcr\n * - --headless Disable browser auto-open, return auth URL instead\n * - --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n * - --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n * - --dcr-verify-url=<url> External verification endpoint (required for external mode)\n * - --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n * - --port=<port> Enable HTTP transport on specified port\n * - --stdio Enable stdio transport (default if no port)\n * - --log-level=<level> Logging level (default: info)\n * - --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-sheets/files)\n * - --base-url=<url> Base URL for HTTP file serving (optional)\n *\n * Environment Variables:\n * - GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n * - GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n * - AUTH_MODE Default authentication mode (optional)\n * - HEADLESS Disable browser auto-open (optional)\n * - DCR_MODE DCR mode (optional, same format as --dcr-mode)\n * - DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n * - DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n * - TOKEN_STORE_URI Token storage URI (optional)\n * - PORT Default HTTP port (optional)\n * - LOG_LEVEL Default logging level (optional)\n * - RESOURCE_STORE_URI Resource store URI (optional, file://)\n * - BASE_URL Base URL for HTTP file serving (optional)\n *\n * OAuth Scopes (from constants.ts):\n * openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive\n */\nexport function parseConfig(args: string[], env: Record<string, string | undefined>): ServerConfig {\n const oauthGoogle = _require('@mcp-z/oauth-google') as typeof OAuthGoogle;\n const mcpServer = _require('@mcp-z/server') as typeof McpServer;\n\n const transportConfig = mcpServer.parseConfig(args, env);\n const oauthConfig = oauthGoogle.parseConfig(args, env);\n\n // Parse DCR configuration if DCR mode is enabled\n const dcrConfig = oauthConfig.auth === 'dcr' ? oauthGoogle.parseDcrConfig(args, env, GOOGLE_SCOPE) : undefined;\n\n // Parse application-level config (LOG_LEVEL, RESOURCE_STORE_URI, BASE_URL)\n const { values } = parseArgs({\n args,\n options: {\n 'log-level': { type: 'string' },\n 'base-url': { type: 'string' },\n 'resource-store-uri': { type: 'string' },\n },\n strict: false, // Allow other arguments\n allowPositionals: true,\n });\n\n const name = pkg.name.replace(/^@[^/]+\\//, '');\n // Parse repository URL from package.json, stripping git+ prefix and .git suffix\n const rawRepoUrl = typeof pkg.repository === 'object' ? pkg.repository.url : pkg.repository;\n const repositoryUrl = rawRepoUrl?.replace(/^git\\+/, '').replace(/\\.git$/, '') ?? `https://github.com/mcp-z/${name}`;\n let rootDir = homedir();\n try {\n const configPath = mcpServer.findConfigPath({ config: '.mcp.json', cwd: process.cwd(), stopDir: homedir() });\n rootDir = path.dirname(configPath);\n } catch {\n rootDir = homedir();\n }\n const baseDir = path.join(rootDir, '.mcp-z');\n const cliLogLevel = typeof values['log-level'] === 'string' ? values['log-level'] : undefined;\n const envLogLevel = env.LOG_LEVEL;\n const logLevel = cliLogLevel ?? envLogLevel ?? 'info';\n\n // Parse storage configuration\n const cliResourceStoreUri = typeof values['resource-store-uri'] === 'string' ? values['resource-store-uri'] : undefined;\n const envResourceStoreUri = env.RESOURCE_STORE_URI;\n const defaultResourceStorePath = path.join(baseDir, name, 'files');\n const resourceStoreUri = normalizeResourceStoreUri(cliResourceStoreUri ?? envResourceStoreUri ?? defaultResourceStorePath);\n\n const cliBaseUrl = typeof values['base-url'] === 'string' ? values['base-url'] : undefined;\n const envBaseUrl = env.BASE_URL;\n const baseUrl = cliBaseUrl ?? envBaseUrl;\n\n // Combine configs\n return {\n ...oauthConfig, // Includes clientId, auth, headless, redirectUri\n transport: transportConfig.transport,\n logLevel,\n baseDir,\n name,\n version: pkg.version,\n repositoryUrl,\n resourceStoreUri,\n ...(baseUrl && { baseUrl }),\n ...(dcrConfig && { dcrConfig }),\n };\n}\n\nfunction normalizeResourceStoreUri(resourceStoreUri: string): string {\n const filePrefix = 'file://';\n if (resourceStoreUri.startsWith(filePrefix)) {\n const rawPath = resourceStoreUri.slice(filePrefix.length);\n const expandedPath = rawPath.startsWith('~') ? rawPath.replace(/^~/, homedir()) : rawPath;\n return `${filePrefix}${path.resolve(expandedPath)}`;\n }\n\n if (resourceStoreUri.includes('://')) return resourceStoreUri;\n\n const expandedPath = resourceStoreUri.startsWith('~') ? resourceStoreUri.replace(/^~/, homedir()) : resourceStoreUri;\n return `${filePrefix}${path.resolve(expandedPath)}`;\n}\n\n/**\n * Build production configuration from process globals.\n * Entry point for production server.\n */\nexport function createConfig(): ServerConfig {\n return parseConfig(process.argv, process.env);\n}\n"],"names":["createConfig","parseConfig","pkg","readPkg","_require","require","Module","createRequire","args","env","cliLogLevel","cliResourceStoreUri","oauthGoogle","mcpServer","transportConfig","oauthConfig","dcrConfig","auth","parseDcrConfig","GOOGLE_SCOPE","undefined","values","parseArgs","options","type","strict","allowPositionals","name","replace","rawRepoUrl","repository","url","repositoryUrl","rootDir","homedir","configPath","findConfigPath","config","cwd","process","stopDir","path","dirname","baseDir","join","envLogLevel","LOG_LEVEL","logLevel","envResourceStoreUri","RESOURCE_STORE_URI","defaultResourceStorePath","resourceStoreUri","normalizeResourceStoreUri","cliBaseUrl","envBaseUrl","BASE_URL","baseUrl","transport","version","filePrefix","startsWith","rawPath","slice","length","expandedPath","resolve","includes","argv"],"mappings":";;;;;;;;;;;QAmIgBA;eAAAA;;QAjFAC;eAAAA;;;sBAhDO;kBACC;4DACF;oBACI;2BACG;6BAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExB,IAAMC,MAAMC,IAAAA,sBAAO;AAEnB,uFAAuF;AACvF,wFAAwF;AACxF,IAAMC,WAAW,OAAOC,YAAY,cAAcC,cAAM,CAACC,aAAa,CAAC,uDAAmBF;AAoCnF,SAASJ,YAAYO,IAAc,EAAEC,GAA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AiBvB,OAAO,CAAC,MAAMM,IAAAA,WAAO,OAAMiB;IACpG,OAAO,AAAC,GAAeV,OAAbkB,YAAwC,OAA3BlB,MAAKwB,OAAO,CAACD;AACtC;AAMO,SAAShE;IACd,OAAOC,YAAYsC,QAAQ4B,IAAI,EAAE5B,QAAQ9B,GAAG;AAC9C"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/setup/config.ts"],"sourcesContent":["import { fileURLToPath, pathToFileURL } from 'node:url';\nimport type * as OAuthGoogle from '@mcp-z/oauth-google';\nimport type * as McpServer from '@mcp-z/server';\nimport { Module } from 'module';\nimport { homedir } from 'os';\nimport * as path from 'path';\nimport { parseArgs } from 'util';\nimport { GOOGLE_SCOPE } from '../constants.ts';\nimport type { ServerConfig } from '../types.ts';\nimport { readPkg } from './version-help.ts';\n\nconst pkg = readPkg();\n\n// @mcp-z/oauth-google and @mcp-z/server are requireable at the >=20 floor; deferred so\n// --version/--help (handled via version-help.ts, never this file) load neither package.\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n/**\n * Parse Sheets server configuration from CLI arguments and environment.\n *\n * CLI Arguments (all optional):\n * - --auth=<mode> Authentication mode (default: loopback-oauth)\n * Modes: loopback-oauth, service-account, dcr\n * - --headless Disable browser auto-open, return auth URL instead\n * - --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n * - --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n * - --dcr-verify-url=<url> External verification endpoint (required for external mode)\n * - --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n * - --port=<port> Enable HTTP transport on specified port\n * - --stdio Enable stdio transport (default if no port)\n * - --log-level=<level> Logging level (default: info)\n * - --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-sheets/files)\n * - --base-url=<url> Base URL for HTTP file serving (optional)\n *\n * Environment Variables:\n * - GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n * - GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n * - AUTH_MODE Default authentication mode (optional)\n * - HEADLESS Disable browser auto-open (optional)\n * - DCR_MODE DCR mode (optional, same format as --dcr-mode)\n * - DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n * - DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n * - TOKEN_STORE_URI Token storage URI (optional)\n * - PORT Default HTTP port (optional)\n * - LOG_LEVEL Default logging level (optional)\n * - RESOURCE_STORE_URI Resource store URI (optional, file://)\n * - BASE_URL Base URL for HTTP file serving (optional)\n *\n * OAuth Scopes (from constants.ts):\n * openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive\n */\nexport function parseConfig(args: string[], env: Record<string, string | undefined>): ServerConfig {\n const oauthGoogle = _require('@mcp-z/oauth-google') as typeof OAuthGoogle;\n const mcpServer = _require('@mcp-z/server') as typeof McpServer;\n\n const transportConfig = mcpServer.parseConfig(args, env);\n const oauthConfig = oauthGoogle.parseConfig(args, env);\n\n // Parse DCR configuration if DCR mode is enabled\n const dcrConfig = oauthConfig.auth === 'dcr' ? oauthGoogle.parseDcrConfig(args, env, GOOGLE_SCOPE) : undefined;\n\n // Parse application-level config (LOG_LEVEL, RESOURCE_STORE_URI, BASE_URL)\n const { values } = parseArgs({\n args,\n options: {\n 'log-level': { type: 'string' },\n 'base-url': { type: 'string' },\n 'resource-store-uri': { type: 'string' },\n },\n strict: false, // Allow other arguments\n allowPositionals: true,\n });\n\n const name = pkg.name.replace(/^@[^/]+\\//, '');\n // Parse repository URL from package.json, stripping git+ prefix and .git suffix\n const rawRepoUrl = typeof pkg.repository === 'object' ? pkg.repository.url : pkg.repository;\n const repositoryUrl = rawRepoUrl?.replace(/^git\\+/, '').replace(/\\.git$/, '') ?? `https://github.com/mcp-z/${name}`;\n let rootDir = homedir();\n try {\n const configPath = mcpServer.findConfigPath({ config: '.mcp.json', cwd: process.cwd(), stopDir: homedir() });\n rootDir = path.dirname(configPath);\n } catch {\n rootDir = homedir();\n }\n const baseDir = path.join(rootDir, '.mcp-z');\n const cliLogLevel = typeof values['log-level'] === 'string' ? values['log-level'] : undefined;\n const envLogLevel = env.LOG_LEVEL;\n const logLevel = cliLogLevel ?? envLogLevel ?? 'info';\n\n // Parse storage configuration\n const cliResourceStoreUri = typeof values['resource-store-uri'] === 'string' ? values['resource-store-uri'] : undefined;\n const envResourceStoreUri = env.RESOURCE_STORE_URI;\n const defaultResourceStorePath = path.join(baseDir, name, 'files');\n const resourceStoreUri = normalizeResourceStoreUri(cliResourceStoreUri ?? envResourceStoreUri ?? defaultResourceStorePath);\n\n const cliBaseUrl = typeof values['base-url'] === 'string' ? values['base-url'] : undefined;\n const envBaseUrl = env.BASE_URL;\n const baseUrl = cliBaseUrl ?? envBaseUrl;\n\n // Combine configs\n return {\n ...oauthConfig, // Includes clientId, auth, headless, redirectUri\n transport: transportConfig.transport,\n logLevel,\n baseDir,\n name,\n version: pkg.version,\n repositoryUrl,\n resourceStoreUri,\n ...(baseUrl && { baseUrl }),\n ...(dcrConfig && { dcrConfig }),\n };\n}\n\nfunction normalizeResourceStoreUri(resourceStoreUri: string): string {\n const filePrefix = 'file://';\n if (resourceStoreUri.startsWith(filePrefix)) {\n const rawPath = resourceStoreUri.slice(filePrefix.length);\n const filePath = rawPath.startsWith('~') ? rawPath.replace(/^~/, homedir()) : rawPath.startsWith('/') ? fileURLToPath(resourceStoreUri) : rawPath;\n return pathToFileURL(path.resolve(filePath)).href;\n }\n\n if (resourceStoreUri.includes('://')) return resourceStoreUri;\n\n const expandedPath = resourceStoreUri.startsWith('~') ? resourceStoreUri.replace(/^~/, homedir()) : resourceStoreUri;\n return pathToFileURL(path.resolve(expandedPath)).href;\n}\n\n/**\n * Build production configuration from process globals.\n * Entry point for production server.\n */\nexport function createConfig(): ServerConfig {\n return parseConfig(process.argv, process.env);\n}\n"],"names":["createConfig","parseConfig","pkg","readPkg","_require","require","Module","createRequire","args","env","cliLogLevel","cliResourceStoreUri","oauthGoogle","mcpServer","transportConfig","oauthConfig","dcrConfig","auth","parseDcrConfig","GOOGLE_SCOPE","undefined","values","parseArgs","options","type","strict","allowPositionals","name","replace","rawRepoUrl","repository","url","repositoryUrl","rootDir","homedir","configPath","findConfigPath","config","cwd","process","stopDir","path","dirname","baseDir","join","envLogLevel","LOG_LEVEL","logLevel","envResourceStoreUri","RESOURCE_STORE_URI","defaultResourceStorePath","resourceStoreUri","normalizeResourceStoreUri","cliBaseUrl","envBaseUrl","BASE_URL","baseUrl","transport","version","filePrefix","startsWith","rawPath","slice","length","filePath","fileURLToPath","pathToFileURL","resolve","href","includes","expandedPath","argv"],"mappings":";;;;;;;;;;;QAoIgBA;eAAAA;;QAjFAC;eAAAA;;;uBAnD6B;sBAGtB;kBACC;4DACF;oBACI;2BACG;6BAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExB,IAAMC,MAAMC,IAAAA,sBAAO;AAEnB,uFAAuF;AACvF,wFAAwF;AACxF,IAAMC,WAAW,OAAOC,YAAY,cAAcC,cAAM,CAACC,aAAa,CAAC,uDAAmBF;AAoCnF,SAASJ,YAAYO,IAAc,EAAEC,GAAuC;cAoChEC,OAMkCC;IAzCnD,IAAMC,cAAcR,SAAS;IAC7B,IAAMS,YAAYT,SAAS;IAE3B,IAAMU,kBAAkBD,UAAUZ,WAAW,CAACO,MAAMC;IACpD,IAAMM,cAAcH,YAAYX,WAAW,CAACO,MAAMC;IAElD,iDAAiD;IACjD,IAAMO,YAAYD,YAAYE,IAAI,KAAK,QAAQL,YAAYM,cAAc,CAACV,MAAMC,KAAKU,yBAAY,IAAIC;IAErG,2EAA2E;IAC3E,IAAM,AAAEC,SAAWC,IAAAA,eAAS,EAAC;QAC3Bd,MAAAA;QACAe,SAAS;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node:url");
|
|
31
32
|
var _oauth = require("@mcp-z/oauth");
|
|
32
33
|
var _server = require("@mcp-z/server");
|
|
33
34
|
var _fs = /*#__PURE__*/ _interop_require_wildcard(require("fs"));
|
|
@@ -215,7 +216,7 @@ function createTokenStore(baseDir) {
|
|
|
215
216
|
return _async_to_generator(function() {
|
|
216
217
|
var tokenStoreUri;
|
|
217
218
|
return _ts_generator(this, function(_state) {
|
|
218
|
-
tokenStoreUri = process.env.TOKEN_STORE_URI ||
|
|
219
|
+
tokenStoreUri = process.env.TOKEN_STORE_URI || (0, _nodeurl.pathToFileURL)(_path.join(baseDir, 'tokens.json')).href;
|
|
219
220
|
return [
|
|
220
221
|
2,
|
|
221
222
|
(0, _createstorets.default)(tokenStoreUri)
|
|
@@ -231,7 +232,7 @@ function createDcrStore(baseDir, required) {
|
|
|
231
232
|
2,
|
|
232
233
|
undefined
|
|
233
234
|
];
|
|
234
|
-
dcrStoreUri = process.env.DCR_STORE_URI ||
|
|
235
|
+
dcrStoreUri = process.env.DCR_STORE_URI || (0, _nodeurl.pathToFileURL)(_path.join(baseDir, 'dcr.json')).href;
|
|
235
236
|
return [
|
|
236
237
|
2,
|
|
237
238
|
(0, _createstorets.default)(dcrStoreUri)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/setup/runtime.ts"],"sourcesContent":["import { sanitizeForLoggingFormatter } from '@mcp-z/oauth';\nimport type { CachedToken } from '@mcp-z/oauth-google';\nimport type { Logger, MiddlewareLayer } from '@mcp-z/server';\nimport { createLoggingMiddleware } from '@mcp-z/server';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport pino from 'pino';\nimport createStore from '../lib/create-store.ts';\nimport * as mcp from '../mcp/index.ts';\nimport type { CommonRuntime, RuntimeDeps, RuntimeOverrides, ServerConfig } from '../types.ts';\nimport { createOAuthAdapters, type OAuthAdapters } from './oauth-google.ts';\n\nexport function createLogger(config: ServerConfig): Logger {\n const hasStdio = config.transport.type === 'stdio';\n const logsPath = path.join(config.baseDir, 'logs', `${config.name}.log`);\n if (hasStdio) fs.mkdirSync(path.dirname(logsPath), { recursive: true });\n return pino({ level: config.logLevel ?? 'info', formatters: sanitizeForLoggingFormatter() }, hasStdio ? pino.destination({ dest: logsPath, sync: false }) : pino.destination(1));\n}\n\nexport async function createTokenStore(baseDir: string) {\n const tokenStoreUri = process.env.TOKEN_STORE_URI ||
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/setup/runtime.ts"],"sourcesContent":["import { pathToFileURL } from 'node:url';\nimport { sanitizeForLoggingFormatter } from '@mcp-z/oauth';\nimport type { CachedToken } from '@mcp-z/oauth-google';\nimport type { Logger, MiddlewareLayer } from '@mcp-z/server';\nimport { createLoggingMiddleware } from '@mcp-z/server';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport pino from 'pino';\nimport createStore from '../lib/create-store.ts';\nimport * as mcp from '../mcp/index.ts';\nimport type { CommonRuntime, RuntimeDeps, RuntimeOverrides, ServerConfig } from '../types.ts';\nimport { createOAuthAdapters, type OAuthAdapters } from './oauth-google.ts';\n\nexport function createLogger(config: ServerConfig): Logger {\n const hasStdio = config.transport.type === 'stdio';\n const logsPath = path.join(config.baseDir, 'logs', `${config.name}.log`);\n if (hasStdio) fs.mkdirSync(path.dirname(logsPath), { recursive: true });\n return pino({ level: config.logLevel ?? 'info', formatters: sanitizeForLoggingFormatter() }, hasStdio ? pino.destination({ dest: logsPath, sync: false }) : pino.destination(1));\n}\n\nexport async function createTokenStore(baseDir: string) {\n const tokenStoreUri = process.env.TOKEN_STORE_URI || pathToFileURL(path.join(baseDir, 'tokens.json')).href;\n return createStore<CachedToken>(tokenStoreUri);\n}\n\nexport async function createDcrStore(baseDir: string, required: boolean) {\n if (!required) return undefined;\n const dcrStoreUri = process.env.DCR_STORE_URI || pathToFileURL(path.join(baseDir, 'dcr.json')).href;\n return createStore<unknown>(dcrStoreUri);\n}\n\nexport function createAuthLayer(authMiddleware: OAuthAdapters['middleware']): MiddlewareLayer {\n return {\n withTool: authMiddleware.withToolAuth,\n withResource: authMiddleware.withResourceAuth,\n withPrompt: authMiddleware.withPromptAuth,\n };\n}\n\nexport function createLoggingLayer(logger: Logger): MiddlewareLayer {\n const logging = createLoggingMiddleware({ logger });\n return {\n withTool: logging.withToolLogging,\n withResource: logging.withResourceLogging,\n withPrompt: logging.withPromptLogging,\n };\n}\n\nexport async function createDefaultRuntime(config: ServerConfig, overrides?: RuntimeOverrides): Promise<CommonRuntime> {\n if (config.auth === 'dcr' && config.transport.type !== 'http') throw new Error('DCR mode requires an HTTP transport');\n\n const logger = createLogger(config);\n const tokenStore = await createTokenStore(config.baseDir);\n const baseUrl = config.baseUrl ?? (config.transport.type === 'http' && config.transport.port ? `http://localhost:${config.transport.port}` : undefined);\n const dcrStore = await createDcrStore(config.baseDir, config.auth === 'dcr');\n const oauthAdapters = await createOAuthAdapters(config, { logger, tokenStore, dcrStore }, baseUrl);\n const deps: RuntimeDeps = { config, logger, tokenStore, oauthAdapters, baseUrl };\n const createDomainModules =\n overrides?.createDomainModules ??\n (() => ({\n tools: Object.values(mcp.toolFactories).map((factory) => factory()),\n resources: Object.values(mcp.resourceFactories).map((factory) => factory()),\n prompts: Object.values(mcp.promptFactories).map((factory) => factory()),\n }));\n const middlewareFactories = overrides?.middlewareFactories ?? [() => createAuthLayer(oauthAdapters.middleware), () => createLoggingLayer(logger)];\n\n return {\n deps,\n middlewareFactories,\n createDomainModules,\n close: async () => {},\n };\n}\n"],"names":["createAuthLayer","createDcrStore","createDefaultRuntime","createLogger","createLoggingLayer","createTokenStore","config","hasStdio","transport","type","logsPath","path","join","baseDir","name","fs","mkdirSync","dirname","recursive","pino","level","logLevel","formatters","sanitizeForLoggingFormatter","destination","dest","sync","tokenStoreUri","process","env","TOKEN_STORE_URI","pathToFileURL","href","createStore","required","dcrStoreUri","undefined","DCR_STORE_URI","authMiddleware","withTool","withToolAuth","withResource","withResourceAuth","withPrompt","withPromptAuth","logger","logging","createLoggingMiddleware","withToolLogging","withResourceLogging","withPromptLogging","overrides","tokenStore","baseUrl","dcrStore","oauthAdapters","deps","createDomainModules","middlewareFactories","auth","Error","port","createOAuthAdapters","tools","Object","values","mcp","toolFactories","map","factory","resources","resourceFactories","prompts","promptFactories","middleware","close"],"mappings":";;;;;;;;;;;QA+BgBA;eAAAA;;QANMC;eAAAA;;QAuBAC;eAAAA;;QAnCNC;eAAAA;;QA0BAC;eAAAA;;QAnBMC;eAAAA;;;uBApBQ;qBACc;sBAGJ;0DACpB;4DACE;2DACL;oEACO;+DACH;6BAEmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjD,SAASF,aAAaG,MAAoB;QAI1BA;IAHrB,IAAMC,WAAWD,OAAOE,SAAS,CAACC,IAAI,KAAK;IAC3C,IAAMC,WAAWC,MAAKC,IAAI,CAACN,OAAOO,OAAO,EAAE,QAAQ,AAAC,GAAc,OAAZP,OAAOQ,IAAI,EAAC;IAClE,IAAIP,UAAUQ,IAAGC,SAAS,CAACL,MAAKM,OAAO,CAACP,WAAW;QAAEQ,WAAW;IAAK;IACrE,OAAOC,IAAAA,aAAI,EAAC;QAAEC,KAAK,GAAEd,mBAAAA,OAAOe,QAAQ,cAAff,8BAAAA,mBAAmB;QAAQgB,YAAYC,IAAAA,kCAA2B;IAAG,GAAGhB,WAAWY,aAAI,CAACK,WAAW,CAAC;QAAEC,MAAMf;QAAUgB,MAAM;IAAM,KAAKP,aAAI,CAACK,WAAW,CAAC;AAC/K;AAEO,SAAenB,iBAAiBQ,OAAe;;YAC9Cc;;YAAAA,gBAAgBC,QAAQC,GAAG,CAACC,eAAe,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,OAAO,EAAEP,OAAOqD,IAAI,KAAK;;;oBAAhEL,WAAW;oBACK;;wBAAMQ,IAAAA,kCAAmB,EAACxD,QAAQ;4BAAEuC,QAAAA;4BAAQO,YAAAA;4BAAYE,UAAAA;wBAAS,GAAGD;;;oBAApFE,gBAAgB;oBAChBC,OAAoB;wBAAElD,QAAAA;wBAAQuC,QAAAA;wBAAQO,YAAAA;wBAAYG,eAAAA;wBAAeF,SAAAA;oBAAQ;oBACzEI,8BACJN,sBAAAA,gCAAAA,UAAWM,mBAAmB,uCAC7B;+BAAO;4BACNM,OAAOC,OAAOC,MAAM,CAACC,SAAIC,aAAa,EAAEC,GAAG,CAAC,SAACC;uCAAYA;;4BACzDC,WAAWN,OAAOC,MAAM,CAACC,SAAIK,iBAAiB,EAAEH,GAAG,CAAC,SAACC;uCAAYA;;4BACjEG,SAASR,OAAOC,MAAM,CAACC,SAAIO,eAAe,EAAEL,GAAG,CAAC,SAACC;uCAAYA;;wBAC/D;;oBACIX,+BAAsBP,sBAAAA,gCAAAA,UAAWO,mBAAmB;wBAAK;mCAAM1D,gBAAgBuD,cAAcmB,UAAU;;wBAAG;mCAAMtE,mBAAmByC;;;oBAEzI;;wBAAO;4BACLW,MAAAA;4BACAE,qBAAAA;4BACAD,qBAAAA;4BACAkB,OAAO,SAAPA;;;;;;;gCAAoB;;wBACtB;;;;IACF"}
|
package/dist/esm/setup/config.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
1
2
|
import { Module } from 'module';
|
|
2
3
|
import { homedir } from 'os';
|
|
3
4
|
import * as path from 'path';
|
|
@@ -115,12 +116,12 @@ function normalizeResourceStoreUri(resourceStoreUri) {
|
|
|
115
116
|
const filePrefix = 'file://';
|
|
116
117
|
if (resourceStoreUri.startsWith(filePrefix)) {
|
|
117
118
|
const rawPath = resourceStoreUri.slice(filePrefix.length);
|
|
118
|
-
const
|
|
119
|
-
return
|
|
119
|
+
const filePath = rawPath.startsWith('~') ? rawPath.replace(/^~/, homedir()) : rawPath.startsWith('/') ? fileURLToPath(resourceStoreUri) : rawPath;
|
|
120
|
+
return pathToFileURL(path.resolve(filePath)).href;
|
|
120
121
|
}
|
|
121
122
|
if (resourceStoreUri.includes('://')) return resourceStoreUri;
|
|
122
123
|
const expandedPath = resourceStoreUri.startsWith('~') ? resourceStoreUri.replace(/^~/, homedir()) : resourceStoreUri;
|
|
123
|
-
return
|
|
124
|
+
return pathToFileURL(path.resolve(expandedPath)).href;
|
|
124
125
|
}
|
|
125
126
|
/**
|
|
126
127
|
* Build production configuration from process globals.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/setup/config.ts"],"sourcesContent":["import type * as OAuthGoogle from '@mcp-z/oauth-google';\nimport type * as McpServer from '@mcp-z/server';\nimport { Module } from 'module';\nimport { homedir } from 'os';\nimport * as path from 'path';\nimport { parseArgs } from 'util';\nimport { GOOGLE_SCOPE } from '../constants.ts';\nimport type { ServerConfig } from '../types.ts';\nimport { readPkg } from './version-help.ts';\n\nconst pkg = readPkg();\n\n// @mcp-z/oauth-google and @mcp-z/server are requireable at the >=20 floor; deferred so\n// --version/--help (handled via version-help.ts, never this file) load neither package.\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n/**\n * Parse Sheets server configuration from CLI arguments and environment.\n *\n * CLI Arguments (all optional):\n * - --auth=<mode> Authentication mode (default: loopback-oauth)\n * Modes: loopback-oauth, service-account, dcr\n * - --headless Disable browser auto-open, return auth URL instead\n * - --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n * - --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n * - --dcr-verify-url=<url> External verification endpoint (required for external mode)\n * - --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n * - --port=<port> Enable HTTP transport on specified port\n * - --stdio Enable stdio transport (default if no port)\n * - --log-level=<level> Logging level (default: info)\n * - --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-sheets/files)\n * - --base-url=<url> Base URL for HTTP file serving (optional)\n *\n * Environment Variables:\n * - GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n * - GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n * - AUTH_MODE Default authentication mode (optional)\n * - HEADLESS Disable browser auto-open (optional)\n * - DCR_MODE DCR mode (optional, same format as --dcr-mode)\n * - DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n * - DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n * - TOKEN_STORE_URI Token storage URI (optional)\n * - PORT Default HTTP port (optional)\n * - LOG_LEVEL Default logging level (optional)\n * - RESOURCE_STORE_URI Resource store URI (optional, file://)\n * - BASE_URL Base URL for HTTP file serving (optional)\n *\n * OAuth Scopes (from constants.ts):\n * openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive\n */\nexport function parseConfig(args: string[], env: Record<string, string | undefined>): ServerConfig {\n const oauthGoogle = _require('@mcp-z/oauth-google') as typeof OAuthGoogle;\n const mcpServer = _require('@mcp-z/server') as typeof McpServer;\n\n const transportConfig = mcpServer.parseConfig(args, env);\n const oauthConfig = oauthGoogle.parseConfig(args, env);\n\n // Parse DCR configuration if DCR mode is enabled\n const dcrConfig = oauthConfig.auth === 'dcr' ? oauthGoogle.parseDcrConfig(args, env, GOOGLE_SCOPE) : undefined;\n\n // Parse application-level config (LOG_LEVEL, RESOURCE_STORE_URI, BASE_URL)\n const { values } = parseArgs({\n args,\n options: {\n 'log-level': { type: 'string' },\n 'base-url': { type: 'string' },\n 'resource-store-uri': { type: 'string' },\n },\n strict: false, // Allow other arguments\n allowPositionals: true,\n });\n\n const name = pkg.name.replace(/^@[^/]+\\//, '');\n // Parse repository URL from package.json, stripping git+ prefix and .git suffix\n const rawRepoUrl = typeof pkg.repository === 'object' ? pkg.repository.url : pkg.repository;\n const repositoryUrl = rawRepoUrl?.replace(/^git\\+/, '').replace(/\\.git$/, '') ?? `https://github.com/mcp-z/${name}`;\n let rootDir = homedir();\n try {\n const configPath = mcpServer.findConfigPath({ config: '.mcp.json', cwd: process.cwd(), stopDir: homedir() });\n rootDir = path.dirname(configPath);\n } catch {\n rootDir = homedir();\n }\n const baseDir = path.join(rootDir, '.mcp-z');\n const cliLogLevel = typeof values['log-level'] === 'string' ? values['log-level'] : undefined;\n const envLogLevel = env.LOG_LEVEL;\n const logLevel = cliLogLevel ?? envLogLevel ?? 'info';\n\n // Parse storage configuration\n const cliResourceStoreUri = typeof values['resource-store-uri'] === 'string' ? values['resource-store-uri'] : undefined;\n const envResourceStoreUri = env.RESOURCE_STORE_URI;\n const defaultResourceStorePath = path.join(baseDir, name, 'files');\n const resourceStoreUri = normalizeResourceStoreUri(cliResourceStoreUri ?? envResourceStoreUri ?? defaultResourceStorePath);\n\n const cliBaseUrl = typeof values['base-url'] === 'string' ? values['base-url'] : undefined;\n const envBaseUrl = env.BASE_URL;\n const baseUrl = cliBaseUrl ?? envBaseUrl;\n\n // Combine configs\n return {\n ...oauthConfig, // Includes clientId, auth, headless, redirectUri\n transport: transportConfig.transport,\n logLevel,\n baseDir,\n name,\n version: pkg.version,\n repositoryUrl,\n resourceStoreUri,\n ...(baseUrl && { baseUrl }),\n ...(dcrConfig && { dcrConfig }),\n };\n}\n\nfunction normalizeResourceStoreUri(resourceStoreUri: string): string {\n const filePrefix = 'file://';\n if (resourceStoreUri.startsWith(filePrefix)) {\n const rawPath = resourceStoreUri.slice(filePrefix.length);\n const expandedPath = rawPath.startsWith('~') ? rawPath.replace(/^~/, homedir()) : rawPath;\n return `${filePrefix}${path.resolve(expandedPath)}`;\n }\n\n if (resourceStoreUri.includes('://')) return resourceStoreUri;\n\n const expandedPath = resourceStoreUri.startsWith('~') ? resourceStoreUri.replace(/^~/, homedir()) : resourceStoreUri;\n return `${filePrefix}${path.resolve(expandedPath)}`;\n}\n\n/**\n * Build production configuration from process globals.\n * Entry point for production server.\n */\nexport function createConfig(): ServerConfig {\n return parseConfig(process.argv, process.env);\n}\n"],"names":["Module","homedir","path","parseArgs","GOOGLE_SCOPE","readPkg","pkg","_require","require","createRequire","url","parseConfig","args","env","cliLogLevel","cliResourceStoreUri","oauthGoogle","mcpServer","transportConfig","oauthConfig","dcrConfig","auth","parseDcrConfig","undefined","values","options","type","strict","allowPositionals","name","replace","rawRepoUrl","repository","repositoryUrl","rootDir","configPath","findConfigPath","config","cwd","process","stopDir","dirname","baseDir","join","envLogLevel","LOG_LEVEL","logLevel","envResourceStoreUri","RESOURCE_STORE_URI","defaultResourceStorePath","resourceStoreUri","normalizeResourceStoreUri","cliBaseUrl","envBaseUrl","BASE_URL","baseUrl","transport","version","filePrefix","startsWith","rawPath","slice","length","expandedPath","resolve","includes","createConfig","argv"],"mappings":"AAEA,SAASA,MAAM,QAAQ,SAAS;AAChC,SAASC,OAAO,QAAQ,KAAK;AAC7B,YAAYC,UAAU,OAAO;AAC7B,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,MAAMC,MAAMD;AAEZ,uFAAuF;AACvF,wFAAwF;AACxF,MAAME,WAAW,OAAOC,YAAY,cAAcR,OAAOS,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCC,GACD,OAAO,SAASG,YAAYC,IAAc,EAAEC,GAAuC;cAoChEC,OAMkCC;IAzCnD,MAAMC,cAAcT,SAAS;IAC7B,MAAMU,YAAYV,SAAS;IAE3B,MAAMW,kBAAkBD,UAAUN,WAAW,CAACC,MAAMC;IACpD,MAAMM,cAAcH,YAAYL,WAAW,CAACC,MAAMC;IAElD,iDAAiD;IACjD,MAAMO,YAAYD,YAAYE,IAAI,KAAK,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 'node:url';\nimport type * as OAuthGoogle from '@mcp-z/oauth-google';\nimport type * as McpServer from '@mcp-z/server';\nimport { Module } from 'module';\nimport { homedir } from 'os';\nimport * as path from 'path';\nimport { parseArgs } from 'util';\nimport { GOOGLE_SCOPE } from '../constants.ts';\nimport type { ServerConfig } from '../types.ts';\nimport { readPkg } from './version-help.ts';\n\nconst pkg = readPkg();\n\n// @mcp-z/oauth-google and @mcp-z/server are requireable at the >=20 floor; deferred so\n// --version/--help (handled via version-help.ts, never this file) load neither package.\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n/**\n * Parse Sheets server configuration from CLI arguments and environment.\n *\n * CLI Arguments (all optional):\n * - --auth=<mode> Authentication mode (default: loopback-oauth)\n * Modes: loopback-oauth, service-account, dcr\n * - --headless Disable browser auto-open, return auth URL instead\n * - --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n * - --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n * - --dcr-verify-url=<url> External verification endpoint (required for external mode)\n * - --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n * - --port=<port> Enable HTTP transport on specified port\n * - --stdio Enable stdio transport (default if no port)\n * - --log-level=<level> Logging level (default: info)\n * - --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-sheets/files)\n * - --base-url=<url> Base URL for HTTP file serving (optional)\n *\n * Environment Variables:\n * - GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n * - GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n * - AUTH_MODE Default authentication mode (optional)\n * - HEADLESS Disable browser auto-open (optional)\n * - DCR_MODE DCR mode (optional, same format as --dcr-mode)\n * - DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n * - DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n * - TOKEN_STORE_URI Token storage URI (optional)\n * - PORT Default HTTP port (optional)\n * - LOG_LEVEL Default logging level (optional)\n * - RESOURCE_STORE_URI Resource store URI (optional, file://)\n * - BASE_URL Base URL for HTTP file serving (optional)\n *\n * OAuth Scopes (from constants.ts):\n * openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive\n */\nexport function parseConfig(args: string[], env: Record<string, string | undefined>): ServerConfig {\n const oauthGoogle = _require('@mcp-z/oauth-google') as typeof OAuthGoogle;\n const mcpServer = _require('@mcp-z/server') as typeof McpServer;\n\n const transportConfig = mcpServer.parseConfig(args, env);\n const oauthConfig = oauthGoogle.parseConfig(args, env);\n\n // Parse DCR configuration if DCR mode is enabled\n const dcrConfig = oauthConfig.auth === 'dcr' ? oauthGoogle.parseDcrConfig(args, env, GOOGLE_SCOPE) : undefined;\n\n // Parse application-level config (LOG_LEVEL, RESOURCE_STORE_URI, BASE_URL)\n const { values } = parseArgs({\n args,\n options: {\n 'log-level': { type: 'string' },\n 'base-url': { type: 'string' },\n 'resource-store-uri': { type: 'string' },\n },\n strict: false, // Allow other arguments\n allowPositionals: true,\n });\n\n const name = pkg.name.replace(/^@[^/]+\\//, '');\n // Parse repository URL from package.json, stripping git+ prefix and .git suffix\n const rawRepoUrl = typeof pkg.repository === 'object' ? pkg.repository.url : pkg.repository;\n const repositoryUrl = rawRepoUrl?.replace(/^git\\+/, '').replace(/\\.git$/, '') ?? `https://github.com/mcp-z/${name}`;\n let rootDir = homedir();\n try {\n const configPath = mcpServer.findConfigPath({ config: '.mcp.json', cwd: process.cwd(), stopDir: homedir() });\n rootDir = path.dirname(configPath);\n } catch {\n rootDir = homedir();\n }\n const baseDir = path.join(rootDir, '.mcp-z');\n const cliLogLevel = typeof values['log-level'] === 'string' ? values['log-level'] : undefined;\n const envLogLevel = env.LOG_LEVEL;\n const logLevel = cliLogLevel ?? envLogLevel ?? 'info';\n\n // Parse storage configuration\n const cliResourceStoreUri = typeof values['resource-store-uri'] === 'string' ? values['resource-store-uri'] : undefined;\n const envResourceStoreUri = env.RESOURCE_STORE_URI;\n const defaultResourceStorePath = path.join(baseDir, name, 'files');\n const resourceStoreUri = normalizeResourceStoreUri(cliResourceStoreUri ?? envResourceStoreUri ?? defaultResourceStorePath);\n\n const cliBaseUrl = typeof values['base-url'] === 'string' ? values['base-url'] : undefined;\n const envBaseUrl = env.BASE_URL;\n const baseUrl = cliBaseUrl ?? envBaseUrl;\n\n // Combine configs\n return {\n ...oauthConfig, // Includes clientId, auth, headless, redirectUri\n transport: transportConfig.transport,\n logLevel,\n baseDir,\n name,\n version: pkg.version,\n repositoryUrl,\n resourceStoreUri,\n ...(baseUrl && { baseUrl }),\n ...(dcrConfig && { dcrConfig }),\n };\n}\n\nfunction normalizeResourceStoreUri(resourceStoreUri: string): string {\n const filePrefix = 'file://';\n if (resourceStoreUri.startsWith(filePrefix)) {\n const rawPath = resourceStoreUri.slice(filePrefix.length);\n const filePath = rawPath.startsWith('~') ? rawPath.replace(/^~/, homedir()) : rawPath.startsWith('/') ? fileURLToPath(resourceStoreUri) : rawPath;\n return pathToFileURL(path.resolve(filePath)).href;\n }\n\n if (resourceStoreUri.includes('://')) return resourceStoreUri;\n\n const expandedPath = resourceStoreUri.startsWith('~') ? resourceStoreUri.replace(/^~/, homedir()) : resourceStoreUri;\n return pathToFileURL(path.resolve(expandedPath)).href;\n}\n\n/**\n * Build production configuration from process globals.\n * Entry point for production server.\n */\nexport function createConfig(): ServerConfig {\n return parseConfig(process.argv, process.env);\n}\n"],"names":["fileURLToPath","pathToFileURL","Module","homedir","path","parseArgs","GOOGLE_SCOPE","readPkg","pkg","_require","require","createRequire","url","parseConfig","args","env","cliLogLevel","cliResourceStoreUri","oauthGoogle","mcpServer","transportConfig","oauthConfig","dcrConfig","auth","parseDcrConfig","undefined","values","options","type","strict","allowPositionals","name","replace","rawRepoUrl","repository","repositoryUrl","rootDir","configPath","findConfigPath","config","cwd","process","stopDir","dirname","baseDir","join","envLogLevel","LOG_LEVEL","logLevel","envResourceStoreUri","RESOURCE_STORE_URI","defaultResourceStorePath","resourceStoreUri","normalizeResourceStoreUri","cliBaseUrl","envBaseUrl","BASE_URL","baseUrl","transport","version","filePrefix","startsWith","rawPath","slice","length","filePath","resolve","href","includes","expandedPath","createConfig","argv"],"mappings":"AAAA,SAASA,aAAa,EAAEC,aAAa,QAAQ,WAAW;AAGxD,SAASC,MAAM,QAAQ,SAAS;AAChC,SAASC,OAAO,QAAQ,KAAK;AAC7B,YAAYC,UAAU,OAAO;AAC7B,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,MAAMC,MAAMD;AAEZ,uFAAuF;AACvF,wFAAwF;AACxF,MAAME,WAAW,OAAOC,YAAY,cAAcR,OAAOS,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCC,GACD,OAAO,SAASG,YAAYC,IAAc,EAAEC,GAAuC;cAoChEC,OAMkCC;IAzCnD,MAAMC,cAAcT,SAAS;IAC7B,MAAMU,YAAYV,SAAS;IAE3B,MAAMW,kBAAkBD,UAAUN,WAAW,CAACC,MAAMC;IACpD,MAAMM,cAAcH,YAAYL,WAAW,CAACC,MAAMC;IAElD,iDAAiD;IACjD,MAAMO,YAAYD,YAAYE,IAAI,KAAK,QAAQL,YAAYM,cAAc,CAACV,MAAMC,KAAKT,gBAAgBmB;IAErG,2EAA2E;IAC3E,MAAM,EAAEC,MAAM,EAAE,GAAGrB,UAAU;QAC3BS;QACAa,SAAS;YACP,aAAa;gBAAEC,MAAM;YAAS;YAC9B,YAAY;gBAAEA,MAAM;YAAS;YAC7B,sBAAsB;gBAAEA,MAAM;YAAS;QACzC;QACAC,QAAQ;QACRC,kBAAkB;IACpB;IAEA,MAAMC,OAAOvB,IAAIuB,IAAI,CAACC,OAAO,CAAC,aAAa;IAC3C,gFAAgF;IAChF,MAAMC,aAAa,OAAOzB,IAAI0B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;QACA4B,SAASnD,IAAImD,OAAO;QACpBxB;QACAiB;QACA,GAAIK,WAAW;YAAEA;QAAQ,CAAC;QAC1B,GAAInC,aAAa;YAAEA;QAAU,CAAC;IAChC;AACF;AAEA,SAAS+B,0BAA0BD,gBAAwB;IACzD,MAAMQ,aAAa;IACnB,IAAIR,iBAAiBS,UAAU,CAACD,aAAa;QAC3C,MAAME,UAAUV,iBAAiBW,KAAK,CAACH,WAAWI,MAAM;QACxD,MAAMC,WAAWH,QAAQD,UAAU,CAAC,OAAOC,QAAQ9B,OAAO,CAAC,MAAM7B,aAAa2D,QAAQD,UAAU,CAAC,OAAO7D,cAAcoD,oBAAoBU;QAC1I,OAAO7D,cAAcG,KAAK8D,OAAO,CAACD,WAAWE,IAAI;IACnD;IAEA,IAAIf,iBAAiBgB,QAAQ,CAAC,QAAQ,OAAOhB;IAE7C,MAAMiB,eAAejB,iBAAiBS,UAAU,CAAC,OAAOT,iBAAiBpB,OAAO,CAAC,MAAM7B,aAAaiD;IACpG,OAAOnD,cAAcG,KAAK8D,OAAO,CAACG,eAAeF,IAAI;AACvD;AAEA;;;CAGC,GACD,OAAO,SAASG;IACd,OAAOzD,YAAY4B,QAAQ8B,IAAI,EAAE9B,QAAQ1B,GAAG;AAC9C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pathToFileURL } from 'node:url';
|
|
1
2
|
import { sanitizeForLoggingFormatter } from '@mcp-z/oauth';
|
|
2
3
|
import { createLoggingMiddleware } from '@mcp-z/server';
|
|
3
4
|
import * as fs from 'fs';
|
|
@@ -22,12 +23,12 @@ export function createLogger(config) {
|
|
|
22
23
|
}) : pino.destination(1));
|
|
23
24
|
}
|
|
24
25
|
export async function createTokenStore(baseDir) {
|
|
25
|
-
const tokenStoreUri = process.env.TOKEN_STORE_URI ||
|
|
26
|
+
const tokenStoreUri = process.env.TOKEN_STORE_URI || pathToFileURL(path.join(baseDir, 'tokens.json')).href;
|
|
26
27
|
return createStore(tokenStoreUri);
|
|
27
28
|
}
|
|
28
29
|
export async function createDcrStore(baseDir, required) {
|
|
29
30
|
if (!required) return undefined;
|
|
30
|
-
const dcrStoreUri = process.env.DCR_STORE_URI ||
|
|
31
|
+
const dcrStoreUri = process.env.DCR_STORE_URI || pathToFileURL(path.join(baseDir, 'dcr.json')).href;
|
|
31
32
|
return createStore(dcrStoreUri);
|
|
32
33
|
}
|
|
33
34
|
export function createAuthLayer(authMiddleware) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/setup/runtime.ts"],"sourcesContent":["import { sanitizeForLoggingFormatter } from '@mcp-z/oauth';\nimport type { CachedToken } from '@mcp-z/oauth-google';\nimport type { Logger, MiddlewareLayer } from '@mcp-z/server';\nimport { createLoggingMiddleware } from '@mcp-z/server';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport pino from 'pino';\nimport createStore from '../lib/create-store.ts';\nimport * as mcp from '../mcp/index.ts';\nimport type { CommonRuntime, RuntimeDeps, RuntimeOverrides, ServerConfig } from '../types.ts';\nimport { createOAuthAdapters, type OAuthAdapters } from './oauth-google.ts';\n\nexport function createLogger(config: ServerConfig): Logger {\n const hasStdio = config.transport.type === 'stdio';\n const logsPath = path.join(config.baseDir, 'logs', `${config.name}.log`);\n if (hasStdio) fs.mkdirSync(path.dirname(logsPath), { recursive: true });\n return pino({ level: config.logLevel ?? 'info', formatters: sanitizeForLoggingFormatter() }, hasStdio ? pino.destination({ dest: logsPath, sync: false }) : pino.destination(1));\n}\n\nexport async function createTokenStore(baseDir: string) {\n const tokenStoreUri = process.env.TOKEN_STORE_URI ||
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/setup/runtime.ts"],"sourcesContent":["import { pathToFileURL } from 'node:url';\nimport { sanitizeForLoggingFormatter } from '@mcp-z/oauth';\nimport type { CachedToken } from '@mcp-z/oauth-google';\nimport type { Logger, MiddlewareLayer } from '@mcp-z/server';\nimport { createLoggingMiddleware } from '@mcp-z/server';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport pino from 'pino';\nimport createStore from '../lib/create-store.ts';\nimport * as mcp from '../mcp/index.ts';\nimport type { CommonRuntime, RuntimeDeps, RuntimeOverrides, ServerConfig } from '../types.ts';\nimport { createOAuthAdapters, type OAuthAdapters } from './oauth-google.ts';\n\nexport function createLogger(config: ServerConfig): Logger {\n const hasStdio = config.transport.type === 'stdio';\n const logsPath = path.join(config.baseDir, 'logs', `${config.name}.log`);\n if (hasStdio) fs.mkdirSync(path.dirname(logsPath), { recursive: true });\n return pino({ level: config.logLevel ?? 'info', formatters: sanitizeForLoggingFormatter() }, hasStdio ? pino.destination({ dest: logsPath, sync: false }) : pino.destination(1));\n}\n\nexport async function createTokenStore(baseDir: string) {\n const tokenStoreUri = process.env.TOKEN_STORE_URI || pathToFileURL(path.join(baseDir, 'tokens.json')).href;\n return createStore<CachedToken>(tokenStoreUri);\n}\n\nexport async function createDcrStore(baseDir: string, required: boolean) {\n if (!required) return undefined;\n const dcrStoreUri = process.env.DCR_STORE_URI || pathToFileURL(path.join(baseDir, 'dcr.json')).href;\n return createStore<unknown>(dcrStoreUri);\n}\n\nexport function createAuthLayer(authMiddleware: OAuthAdapters['middleware']): MiddlewareLayer {\n return {\n withTool: authMiddleware.withToolAuth,\n withResource: authMiddleware.withResourceAuth,\n withPrompt: authMiddleware.withPromptAuth,\n };\n}\n\nexport function createLoggingLayer(logger: Logger): MiddlewareLayer {\n const logging = createLoggingMiddleware({ logger });\n return {\n withTool: logging.withToolLogging,\n withResource: logging.withResourceLogging,\n withPrompt: logging.withPromptLogging,\n };\n}\n\nexport async function createDefaultRuntime(config: ServerConfig, overrides?: RuntimeOverrides): Promise<CommonRuntime> {\n if (config.auth === 'dcr' && config.transport.type !== 'http') throw new Error('DCR mode requires an HTTP transport');\n\n const logger = createLogger(config);\n const tokenStore = await createTokenStore(config.baseDir);\n const baseUrl = config.baseUrl ?? (config.transport.type === 'http' && config.transport.port ? `http://localhost:${config.transport.port}` : undefined);\n const dcrStore = await createDcrStore(config.baseDir, config.auth === 'dcr');\n const oauthAdapters = await createOAuthAdapters(config, { logger, tokenStore, dcrStore }, baseUrl);\n const deps: RuntimeDeps = { config, logger, tokenStore, oauthAdapters, baseUrl };\n const createDomainModules =\n overrides?.createDomainModules ??\n (() => ({\n tools: Object.values(mcp.toolFactories).map((factory) => factory()),\n resources: Object.values(mcp.resourceFactories).map((factory) => factory()),\n prompts: Object.values(mcp.promptFactories).map((factory) => factory()),\n }));\n const middlewareFactories = overrides?.middlewareFactories ?? [() => createAuthLayer(oauthAdapters.middleware), () => createLoggingLayer(logger)];\n\n return {\n deps,\n middlewareFactories,\n createDomainModules,\n close: async () => {},\n };\n}\n"],"names":["pathToFileURL","sanitizeForLoggingFormatter","createLoggingMiddleware","fs","path","pino","createStore","mcp","createOAuthAdapters","createLogger","config","hasStdio","transport","type","logsPath","join","baseDir","name","mkdirSync","dirname","recursive","level","logLevel","formatters","destination","dest","sync","createTokenStore","tokenStoreUri","process","env","TOKEN_STORE_URI","href","createDcrStore","required","undefined","dcrStoreUri","DCR_STORE_URI","createAuthLayer","authMiddleware","withTool","withToolAuth","withResource","withResourceAuth","withPrompt","withPromptAuth","createLoggingLayer","logger","logging","withToolLogging","withResourceLogging","withPromptLogging","createDefaultRuntime","overrides","auth","Error","tokenStore","baseUrl","port","dcrStore","oauthAdapters","deps","createDomainModules","tools","Object","values","toolFactories","map","factory","resources","resourceFactories","prompts","promptFactories","middlewareFactories","middleware","close"],"mappings":"AAAA,SAASA,aAAa,QAAQ,WAAW;AACzC,SAASC,2BAA2B,QAAQ,eAAe;AAG3D,SAASC,uBAAuB,QAAQ,gBAAgB;AACxD,YAAYC,QAAQ,KAAK;AACzB,YAAYC,UAAU,OAAO;AAC7B,OAAOC,UAAU,OAAO;AACxB,OAAOC,iBAAiB,yBAAyB;AACjD,YAAYC,SAAS,kBAAkB;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ACtB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-z/mcp-sheets",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "MCP server for Google Sheets integration with OAuth authentication, spreadsheet management, batch operations, and advanced formatting",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sheets",
|
|
@@ -60,14 +60,16 @@
|
|
|
60
60
|
"format": "tsds format",
|
|
61
61
|
"prepublish:check": "ncp",
|
|
62
62
|
"prepublishOnly": "node scripts/require-dist-tag.cjs && tsds validate",
|
|
63
|
-
"test": "tsds test:node --no-timeouts",
|
|
64
|
-
"test:
|
|
63
|
+
"test": "tsds test:node --require test/lib/env-loader.ts --no-timeouts",
|
|
64
|
+
"test:ci": "tsds test:node --require test/lib/env-loader.ts --no-timeouts --ignore \"test/integration/**\" --ignore \"test/unit/mcp/tools/csv-get-columns.test.ts\"",
|
|
65
|
+
"test:ci:engines": "nvu engines tsds test:node --require test/lib/env-loader.ts --no-timeouts --ignore \"test/integration/**\" --ignore \"test/unit/mcp/tools/csv-get-columns.test.ts\"",
|
|
66
|
+
"test:engines": "nvu engines tsds test:node --require test/lib/env-loader.ts --no-timeouts",
|
|
65
67
|
"test:setup": "node scripts/setup-test.ts",
|
|
66
68
|
"version": "tsds version"
|
|
67
69
|
},
|
|
68
70
|
"dependencies": {
|
|
69
|
-
"@googleapis/drive": "^
|
|
70
|
-
"@googleapis/sheets": "^
|
|
71
|
+
"@googleapis/drive": "^26.0.0",
|
|
72
|
+
"@googleapis/sheets": "^18.0.0",
|
|
71
73
|
"@mcp-z/oauth": "^2.0.0",
|
|
72
74
|
"@mcp-z/oauth-google": "^2.0.1",
|
|
73
75
|
"@mcp-z/server": "^2.2.0",
|
|
@@ -91,8 +93,10 @@
|
|
|
91
93
|
"get-port": "5.1.1",
|
|
92
94
|
"keyv": "^5.0.0",
|
|
93
95
|
"node-version-use": "^2.4.7",
|
|
96
|
+
"p-throttle": "^8.1.1",
|
|
94
97
|
"ts-dev-stack": "^1.22.1",
|
|
95
|
-
"tsds-config": "^1.0.4"
|
|
98
|
+
"tsds-config": "^1.0.4",
|
|
99
|
+
"tsds-lib": "^1.22.6"
|
|
96
100
|
},
|
|
97
101
|
"engines": {
|
|
98
102
|
"node": ">=20"
|