dropsh 0.7.3 → 0.8.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 CHANGED
@@ -599,6 +599,8 @@ shipped inside the `dropsh` npm tarball — each is a separately published packa
599
599
  | [`@dropsh/plugin-schemata`](plugins/schemata/README.md) | `schemataPlugin` | authoritative JSON Schema from Drupal `schemata` (legacy) |
600
600
  | [`@dropsh/plugin-canvas`](plugins/canvas/README.md) | `canvasPlugin` | Canvas component schemas from `jsonapi_sdc` |
601
601
  | [`@dropsh/plugin-display-builder`](plugins/display-builder/README.md) | `displayBuilderPlugin` | Display Builder operation schemas and metadata |
602
+ | [`@dropsh/plugin-mcp`](plugins/mcp/README.md) | `mcpPlugin` | Model Context Protocol server (stdio and loopback HTTP) |
603
+ | [`@dropsh/plugin-tool`](plugins/tool/README.md) | `toolPlugin` | list and call Drupal Tool API tools over the site's `mcp_server` endpoint |
602
604
 
603
605
  Basic auth is not a separate package — its `basicAuthPlugin` factory ships in the
604
606
  core CLI's `dropsh/plugin` entry.
@@ -52,6 +52,11 @@ export interface AdapterRuntime {
52
52
  now(): number;
53
53
  /** Persist a refreshed session back to the active session slot. */
54
54
  save(session: AuthSession): Promise<void>;
55
+ /**
56
+ * Re-read the persisted session slot. Other processes sharing the slot may have
57
+ * renewed (and rotated the refresh token) since this adapter was created.
58
+ */
59
+ load?(): Promise<AuthSession | undefined>;
55
60
  }
56
61
  export interface AuthProvider {
57
62
  readonly id: string;
@@ -0,0 +1,17 @@
1
+ import type { AuthAdapter } from "./auth/types.js";
2
+ import type { HttpClient } from "./http.js";
3
+ import type { JsonApiClient } from "./jsonapi/client.js";
4
+ import type { DropSHPlugin } from "./plugin.js";
5
+ export interface CommandContext {
6
+ client: JsonApiClient;
7
+ http: HttpClient;
8
+ auth: AuthAdapter;
9
+ baseUrl: string;
10
+ jsonapiPrefix: string;
11
+ cwd: string;
12
+ plugins: DropSHPlugin[];
13
+ }
14
+ export interface PluginCommandServices {
15
+ getContext(auth?: AuthAdapter): Promise<CommandContext>;
16
+ stderr(message: string): void;
17
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,7 @@
1
1
  import type { Command } from "commander";
2
2
  import type { AuthAdapter, AuthProvider } from "./auth/types.js";
3
3
  import type { AnyRenderer } from "./cli/render.js";
4
+ import type { PluginCommandServices } from "./command-context.js";
4
5
  import type { HttpClient, HttpRequest } from "./http.js";
5
6
  import type { DropSHOperation } from "./jsonapi/client.js";
6
7
  import type { Operation } from "./schema/to-jsonschema.js";
@@ -57,7 +58,7 @@ export interface DropSHPlugin {
57
58
  extendSchema?(entityType: string, bundle: string, baseSchema: unknown, ctx: PluginContext): Promise<unknown>;
58
59
  extendOperationSchema?(entityType: string, bundle: string, operation: SchemaOperation, operationSchema: unknown, ctx: PluginContext): Promise<unknown>;
59
60
  alterRequest?(req: HttpRequest, ctx: RequestContext): Promise<HttpRequest>;
60
- registerCommands?(program: Command): void;
61
+ registerCommands?(program: Command, services: PluginCommandServices): void;
61
62
  renderers?: AnyRenderer[];
62
63
  }
63
64
  /**
@@ -1,20 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
3
  import type { AuthAdapter, AuthStatusInfo } from "./core/auth/types.js";
4
+ import type { CommandContext } from "./core/command-context.js";
4
5
  import type { HttpClient } from "./core/http.js";
5
- import { type JsonApiClient } from "./core/jsonapi/client.js";
6
6
  import type { DropSHPlugin } from "./core/plugin.js";
7
- export interface CommandContext {
8
- client: JsonApiClient;
9
- http: HttpClient;
10
- auth: AuthAdapter;
11
- baseUrl: string;
12
- jsonapiPrefix: string;
13
- cwd: string;
14
- plugins: DropSHPlugin[];
15
- }
7
+ export type { CommandContext, PluginCommandServices } from "./core/command-context.js";
16
8
  export interface ProgramOptions {
17
- contextFactory?: () => Promise<CommandContext>;
9
+ contextFactory?: (auth?: AuthAdapter) => Promise<CommandContext>;
18
10
  stdout?: (s: string) => void;
19
11
  stderr?: (s: string) => void;
20
12
  setExitCode?: (code: number) => void;
package/dist/src/index.js CHANGED
@@ -9,7 +9,7 @@ import { runDelete } from "./commands/delete.js";
9
9
  import { runRead } from "./commands/read.js";
10
10
  import { applyOperationSchemaPlugins, operationHookPluginIds, runSchema, SCHEMA_PIPELINE_VERSION, schemaCacheMetadataMatches, siteCacheRoot, } from "./commands/schema.js";
11
11
  import { runSearch } from "./commands/search.js";
12
- import { assertUpdateTarget, runUpdate, } from "./commands/update.js";
12
+ import { assertUpdateTarget, runUpdate } from "./commands/update.js";
13
13
  import { runUploadFile } from "./commands/upload-file.js";
14
14
  import { collectProviders, defaultProvider, providerById, sessionlessProvider, } from "./core/auth/registry.js";
15
15
  import { readProfiles, writeProfile } from "./core/auth/session-store.js";
@@ -68,6 +68,7 @@ export async function resolveAuth(deps) {
68
68
  http: deps.http,
69
69
  now: deps.now,
70
70
  save: (session) => writeProfile(deps.baseUrl, name, provider.id, session, deps.stateDir),
71
+ load: async () => (await readProfiles(deps.baseUrl, deps.stateDir))?.profiles[name]?.session,
71
72
  });
72
73
  }
73
74
  // No stored session for the chosen profile: a login-less provider carries its
@@ -113,16 +114,20 @@ export async function authStatus(deps) {
113
114
  }
114
115
  return provider.status(rec.session);
115
116
  }
116
- async function defaultContext(configPath, profile) {
117
+ async function defaultContext(configPath, profile, authOverride) {
117
118
  const cfg = await loadConfig(configPath);
118
- const http = createHttpClient({ timeoutMs: cfg.defaults.timeout_ms });
119
- const auth = await resolveAuth({
120
- baseUrl: cfg.site.base_url,
121
- plugins: cfg.plugins,
122
- http,
123
- now: Date.now,
124
- ...(profile !== undefined ? { profile } : {}),
119
+ const http = createHttpClient({
120
+ timeoutMs: cfg.defaults.timeout_ms,
121
+ ...(authOverride !== undefined ? { maxRetries: 0 } : {}),
125
122
  });
123
+ const auth = authOverride ??
124
+ (await resolveAuth({
125
+ baseUrl: cfg.site.base_url,
126
+ plugins: cfg.plugins,
127
+ http,
128
+ now: Date.now,
129
+ ...(profile !== undefined ? { profile } : {}),
130
+ }));
126
131
  const pluginContext = {
127
132
  http,
128
133
  auth,
@@ -183,10 +188,16 @@ export function buildProgram(opts = {}) {
183
188
  });
184
189
  }
185
190
  const contextFactory = opts.contextFactory ??
186
- (() => {
191
+ ((auth) => {
187
192
  const profile = program.opts().authProfile ?? process.env.DROPSH_AUTH_PROFILE;
188
- return defaultContext(currentConfigSource().path, profile);
193
+ return auth !== undefined
194
+ ? defaultContext(currentConfigSource().path, profile, auth)
195
+ : defaultContext(currentConfigSource().path, profile);
189
196
  });
197
+ const commandServices = {
198
+ getContext: (auth) => auth !== undefined ? contextFactory(auth) : contextFactory(),
199
+ stderr,
200
+ };
190
201
  const renderers = (opts.plugins ?? []).flatMap((p) => p.renderers ?? []);
191
202
  const output = createOutput({
192
203
  stdout,
@@ -591,7 +602,7 @@ Example:
591
602
  .action((o) => run2(async () => runAuthStatus(o, await authDeps())));
592
603
  if (opts.plugins) {
593
604
  for (const plugin of opts.plugins) {
594
- plugin.registerCommands?.(program);
605
+ plugin.registerCommands?.(program, commandServices);
595
606
  }
596
607
  }
597
608
  program.exitOverride();
@@ -1,8 +1,19 @@
1
+ export { readDataArg } from "./commands/_data.js";
2
+ export type { CreateArgs, CreateDeps } from "./commands/create.js";
3
+ export { runCreate } from "./commands/create.js";
4
+ export type { ReadArgs, ReadDeps } from "./commands/read.js";
5
+ export { runRead } from "./commands/read.js";
6
+ export { applyOperationSchemaPlugins } from "./commands/schema.js";
7
+ export type { SearchArgs, SearchDeps } from "./commands/search.js";
8
+ export { runSearch } from "./commands/search.js";
9
+ export type { UpdateArgs, UpdateDeps } from "./commands/update.js";
10
+ export { runUpdate } from "./commands/update.js";
1
11
  export type { BasicAuthConfig } from "./core/auth/basic.js";
2
12
  export { basicAuthPlugin, basicAuthProvider } from "./core/auth/basic.js";
3
13
  export type { AdapterRuntime, AuthAdapter, AuthContext, AuthProvider, AuthSession, AuthStatusInfo, } from "./core/auth/types.js";
4
14
  export type { AnyRenderer, InteractiveRenderer, RenderContext, Renderer, RenderServices, } from "./core/cli/render.js";
5
15
  export { indexIncluded, isInteractive } from "./core/cli/render.js";
16
+ export type { CommandContext, PluginCommandServices } from "./core/command-context.js";
6
17
  export type { Config, SiteConfig } from "./core/config.js";
7
18
  export { loadConfig } from "./core/config.js";
8
19
  export type { ConfigSource, ConfigSourceKind, ConnectionEntry, ResolveConfigSourceInput, ResolveConnectionsDirInput, } from "./core/connections.js";
@@ -21,5 +32,9 @@ export type { FieldDescriptor, SchemaFieldIndex } from "./core/params/schema-fie
21
32
  export { indexSchemaFields, propertiesOf } from "./core/params/schema-fields.js";
22
33
  export type { DropSHPlugin, PluginContext, PluginDescriptor, RequestContext, SchemaOperation, } from "./core/plugin.js";
23
34
  export { composePlugins } from "./core/plugin.js";
24
- export { AuthError, ConfigError, HttpError, PluginError } from "./errors.js";
25
- export type { CommandContext } from "./index.js";
35
+ export { fetchCatalog } from "./core/schema/catalog.js";
36
+ export { fetchJsonSchema } from "./core/schema/jsonschema-source.js";
37
+ export type { Operation } from "./core/schema/to-jsonschema.js";
38
+ export { toOperationVariant } from "./core/schema/to-jsonschema.js";
39
+ export { validatePayload } from "./core/schema/validate.js";
40
+ export { AuthError, CliError, ConfigError, exitCodeFor, HttpError, PluginError, ValidationError, } from "./errors.js";
@@ -1,3 +1,9 @@
1
+ export { readDataArg } from "./commands/_data.js";
2
+ export { runCreate } from "./commands/create.js";
3
+ export { runRead } from "./commands/read.js";
4
+ export { applyOperationSchemaPlugins } from "./commands/schema.js";
5
+ export { runSearch } from "./commands/search.js";
6
+ export { runUpdate } from "./commands/update.js";
1
7
  export { basicAuthPlugin, basicAuthProvider } from "./core/auth/basic.js";
2
8
  export { indexIncluded, isInteractive } from "./core/cli/render.js";
3
9
  export { loadConfig } from "./core/config.js";
@@ -7,4 +13,8 @@ export { createJsonApiClient } from "./core/jsonapi/client.js";
7
13
  export { buildPayloadFromParameters } from "./core/params/from-parameters.js";
8
14
  export { indexSchemaFields, propertiesOf } from "./core/params/schema-fields.js";
9
15
  export { composePlugins } from "./core/plugin.js";
10
- export { AuthError, ConfigError, HttpError, PluginError } from "./errors.js";
16
+ export { fetchCatalog } from "./core/schema/catalog.js";
17
+ export { fetchJsonSchema } from "./core/schema/jsonschema-source.js";
18
+ export { toOperationVariant } from "./core/schema/to-jsonschema.js";
19
+ export { validatePayload } from "./core/schema/validate.js";
20
+ export { AuthError, CliError, ConfigError, exitCodeFor, HttpError, PluginError, ValidationError, } from "./errors.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dropsh",
3
- "version": "0.7.3",
3
+ "version": "0.8.2",
4
4
  "description": "Entity-agnostic helper CLI for Drupal 11 JSON:API, used by the dropsh Claude skill for editorial publishing workflows.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -48,6 +48,7 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@biomejs/biome": "^2.4.14",
51
+ "@modelcontextprotocol/sdk": "1.32.1",
51
52
  "@types/node": "^20.14.0",
52
53
  "tsx": "^4.19.0",
53
54
  "typescript": "^5.6.0",