@displaydev/cli 0.9.0 → 0.11.0
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/mcp-server.js +149 -20
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -198,7 +198,9 @@ function okResponse(result) {
|
|
|
198
198
|
/**
|
|
199
199
|
* Starts an MCP server over stdin/stdout.
|
|
200
200
|
* Tools call the display.dev REST API via the ApiClient.
|
|
201
|
-
*/
|
|
201
|
+
*/ var AUTHENTICATED_INSTRUCTIONS = 'display.dev publishes HTML or Markdown artifacts to permanent URLs gated by company authentication — ideal for sharing AI-generated reports, dashboards, or explainers with the user\'s team.';
|
|
202
|
+
var PUBLIC_INSTRUCTIONS = 'display.dev publishes anonymous HTML or Markdown artifacts. Returns a preview URL (anyone can view) plus a one-shot claim URL the user visits to move the artifact into a display.dev organization.';
|
|
203
|
+
export function startMcpServer(_0) {
|
|
202
204
|
return _async_to_generator(function(apiClient) {
|
|
203
205
|
var options, _options_mode, _options_transport, mode, server, transport;
|
|
204
206
|
var _arguments = arguments;
|
|
@@ -210,6 +212,8 @@ function okResponse(result) {
|
|
|
210
212
|
server = new McpServer({
|
|
211
213
|
name: 'display',
|
|
212
214
|
version: '1.0.0'
|
|
215
|
+
}, {
|
|
216
|
+
instructions: mode === 'public' ? PUBLIC_INSTRUCTIONS : AUTHENTICATED_INSTRUCTIONS
|
|
213
217
|
});
|
|
214
218
|
if (mode === 'public') {
|
|
215
219
|
registerPublicTools(server, apiClient);
|
|
@@ -693,17 +697,77 @@ export function registerTools(server, api) {
|
|
|
693
697
|
});
|
|
694
698
|
})();
|
|
695
699
|
});
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
700
|
+
server.tool('share', 'Change an artifact\'s visibility and/or add/remove individual shared-with emails without republishing.', {
|
|
701
|
+
short_id: z.string().describe('Short ID of the artifact (8 chars).'),
|
|
702
|
+
visibility: z.enum([
|
|
703
|
+
'public',
|
|
704
|
+
'company',
|
|
705
|
+
'private'
|
|
706
|
+
]).optional().describe('Change the visibility level. Omit to keep current. "private" requires the Pro plan.'),
|
|
707
|
+
add_users: z.array(z.string()).optional().describe('Emails to add to sharedWith (idempotent).'),
|
|
708
|
+
remove_users: z.array(z.string()).optional().describe('Emails to remove from sharedWith (idempotent).')
|
|
709
|
+
}, function(args) {
|
|
710
|
+
return _async_to_generator(function() {
|
|
711
|
+
var result, err;
|
|
712
|
+
return _ts_generator(this, function(_state) {
|
|
713
|
+
switch(_state.label){
|
|
714
|
+
case 0:
|
|
715
|
+
if (args.visibility === undefined && !args.add_users && !args.remove_users) {
|
|
716
|
+
return [
|
|
717
|
+
2,
|
|
718
|
+
{
|
|
719
|
+
content: [
|
|
720
|
+
{
|
|
721
|
+
type: 'text',
|
|
722
|
+
text: JSON.stringify({
|
|
723
|
+
error: 'invalid_input',
|
|
724
|
+
message: 'Provide at least one of visibility, add_users, or remove_users'
|
|
725
|
+
})
|
|
726
|
+
}
|
|
727
|
+
],
|
|
728
|
+
isError: true
|
|
729
|
+
}
|
|
730
|
+
];
|
|
731
|
+
}
|
|
732
|
+
_state.label = 1;
|
|
733
|
+
case 1:
|
|
734
|
+
_state.trys.push([
|
|
735
|
+
1,
|
|
736
|
+
3,
|
|
737
|
+
,
|
|
738
|
+
4
|
|
739
|
+
]);
|
|
740
|
+
return [
|
|
741
|
+
4,
|
|
742
|
+
api.share(args.short_id, {
|
|
743
|
+
visibility: args.visibility,
|
|
744
|
+
addUsers: args.add_users,
|
|
745
|
+
removeUsers: args.remove_users
|
|
746
|
+
})
|
|
747
|
+
];
|
|
748
|
+
case 2:
|
|
749
|
+
result = _state.sent();
|
|
750
|
+
return [
|
|
751
|
+
2,
|
|
752
|
+
okResponse(result)
|
|
753
|
+
];
|
|
754
|
+
case 3:
|
|
755
|
+
err = _state.sent();
|
|
756
|
+
return [
|
|
757
|
+
2,
|
|
758
|
+
errorResponse(err)
|
|
759
|
+
];
|
|
760
|
+
case 4:
|
|
761
|
+
return [
|
|
762
|
+
2
|
|
763
|
+
];
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
})();
|
|
767
|
+
});
|
|
768
|
+
server.tool('rename', 'Rename a published artifact. The URL slug updates to match; existing URLs still resolve because routing uses the shortId.', {
|
|
769
|
+
short_id: z.string().describe('The 8-character shortId returned at publish.'),
|
|
770
|
+
name: z.string().describe('New display name. 1–200 characters.')
|
|
707
771
|
}, function(args) {
|
|
708
772
|
return _async_to_generator(function() {
|
|
709
773
|
var result, err;
|
|
@@ -718,13 +782,73 @@ export function registerTools(server, api) {
|
|
|
718
782
|
]);
|
|
719
783
|
return [
|
|
720
784
|
4,
|
|
721
|
-
api.
|
|
785
|
+
api.renameArtifact(args.short_id, args.name)
|
|
722
786
|
];
|
|
723
787
|
case 1:
|
|
724
788
|
result = _state.sent();
|
|
725
789
|
return [
|
|
726
790
|
2,
|
|
727
|
-
okResponse(
|
|
791
|
+
okResponse({
|
|
792
|
+
url: result.url,
|
|
793
|
+
shortId: result.shortId,
|
|
794
|
+
name: result.name
|
|
795
|
+
})
|
|
796
|
+
];
|
|
797
|
+
case 2:
|
|
798
|
+
err = _state.sent();
|
|
799
|
+
return [
|
|
800
|
+
2,
|
|
801
|
+
errorResponse(err)
|
|
802
|
+
];
|
|
803
|
+
case 3:
|
|
804
|
+
return [
|
|
805
|
+
2
|
|
806
|
+
];
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
})();
|
|
810
|
+
});
|
|
811
|
+
server.tool('export', 'Retrieve the source bytes of a published artifact. `format: "original"` returns the publisher\'s upload (markdown for .md, HTML for .html). `format: "markdown"` always returns markdown — `.md` is unchanged, `.html` is converted via Workers AI (cached).', {
|
|
812
|
+
short_id: z.string().describe('Short ID of the artifact (8 chars).'),
|
|
813
|
+
version: z.number().int().min(1).optional().describe('Pinned version number. Omit for current.'),
|
|
814
|
+
format: z.enum([
|
|
815
|
+
'original',
|
|
816
|
+
'markdown'
|
|
817
|
+
]).default('original').describe('Representation requested. Default "original".')
|
|
818
|
+
}, function(args) {
|
|
819
|
+
return _async_to_generator(function() {
|
|
820
|
+
var result, err;
|
|
821
|
+
return _ts_generator(this, function(_state) {
|
|
822
|
+
switch(_state.label){
|
|
823
|
+
case 0:
|
|
824
|
+
_state.trys.push([
|
|
825
|
+
0,
|
|
826
|
+
2,
|
|
827
|
+
,
|
|
828
|
+
3
|
|
829
|
+
]);
|
|
830
|
+
return [
|
|
831
|
+
4,
|
|
832
|
+
api.exportSource(args.short_id, args.version, args.format)
|
|
833
|
+
];
|
|
834
|
+
case 1:
|
|
835
|
+
result = _state.sent();
|
|
836
|
+
return [
|
|
837
|
+
2,
|
|
838
|
+
{
|
|
839
|
+
content: [
|
|
840
|
+
{
|
|
841
|
+
type: 'text',
|
|
842
|
+
text: result.data.toString('utf-8')
|
|
843
|
+
}
|
|
844
|
+
],
|
|
845
|
+
_meta: {
|
|
846
|
+
shortId: args.short_id,
|
|
847
|
+
version: args.version,
|
|
848
|
+
contentType: result.contentType,
|
|
849
|
+
sizeBytes: result.data.length
|
|
850
|
+
}
|
|
851
|
+
}
|
|
728
852
|
];
|
|
729
853
|
case 2:
|
|
730
854
|
err = _state.sent();
|
|
@@ -740,11 +864,16 @@ export function registerTools(server, api) {
|
|
|
740
864
|
});
|
|
741
865
|
})();
|
|
742
866
|
});
|
|
743
|
-
//
|
|
744
|
-
//
|
|
745
|
-
//
|
|
746
|
-
server.tool('
|
|
747
|
-
|
|
867
|
+
// Metadata-only: does NOT bump the artifact version. Use the `publish`
|
|
868
|
+
// tool (with `show_branding`) when you're changing content at the same
|
|
869
|
+
// time so both writes happen in one transaction.
|
|
870
|
+
server.tool('branding', 'Override display.dev branding for an existing artifact without re-publishing. Paid tiers only (free-tier orgs must keep inherit).', {
|
|
871
|
+
short_id: z.string().describe('Artifact shortId'),
|
|
872
|
+
show_branding: z.enum([
|
|
873
|
+
'show',
|
|
874
|
+
'hide',
|
|
875
|
+
'inherit'
|
|
876
|
+
]).describe('show = force branding on; hide = force off; inherit = follow org default')
|
|
748
877
|
}, function(args) {
|
|
749
878
|
return _async_to_generator(function() {
|
|
750
879
|
var result, err;
|
|
@@ -759,7 +888,7 @@ export function registerTools(server, api) {
|
|
|
759
888
|
]);
|
|
760
889
|
return [
|
|
761
890
|
4,
|
|
762
|
-
api.
|
|
891
|
+
api.setArtifactBranding(args.short_id, args.show_branding)
|
|
763
892
|
];
|
|
764
893
|
case 1:
|
|
765
894
|
result = _state.sent();
|