-
Notifications
You must be signed in to change notification settings - Fork 5.8k
grain: AI-optimize MCP action set #21958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
michelle0927
wants to merge
8
commits into
master
Choose a base branch
from
mcp/grain
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d8265a8
feat(grain): AI-optimize action set with 6 new tools
michelle0927 159052e
chore(grain): bump instant source versions to 1.0.1
michelle0927 cf4d511
fix(grain): address CodeRabbit review feedback on descriptions
michelle0927 3297f08
fix(grain): parse JSON-encoded string[] props defensively
michelle0927 a2a7f5f
fix(grain): address council review findings
michelle0927 686f515
fix(grain): bound dedup ID length, add concrete IDs to filter descrip…
michelle0927 20997ee
Merge branch 'master' into mcp/grain
vetrivigneshwaran a2b9635
updates per review
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
components/grain/actions/download-recording/download-recording.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import fs from "fs"; | ||
| import grain from "../../grain.app.mjs"; | ||
|
|
||
| const EXTENSION_BY_CONTENT_TYPE = { | ||
| "video/mp4": "mp4", | ||
| "video/quicktime": "mov", | ||
| "audio/mpeg": "mp3", | ||
| "audio/mp4": "m4a", | ||
| }; | ||
| const DEFAULT_EXTENSION = "mp4"; | ||
|
|
||
| export default { | ||
| key: "grain-download-recording", | ||
| name: "Download Recording", | ||
| description: "Downloads a Grain recording's media file (video or audio) and returns a presigned download URL." | ||
| + " Only recordings with processed media have a downloadable file — check `media_type` (`video` or `audio`, not `transcript`) from **List Recordings** or **Get Recording** first." | ||
| + " Use **Get Transcript** instead if you only need the spoken content, not the media file itself." | ||
| + " Example: `recordingId: \"8a089fcb-0961-4393-8da2-f0db5f8cfd79\"` downloads the file and returns `{\"filePath\": \"/tmp/grain-recording-8a089fcb-....mp4\", \"filename\": \"grain-recording-8a089fcb-....mp4\", \"contentType\": \"video/mp4\"}`." | ||
| + " [See the documentation](https://developers.grain.com/#download-recording)", | ||
| version: "0.0.1", | ||
|
michelle0927 marked this conversation as resolved.
|
||
| ai: "optimized", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| grain, | ||
| recordingId: { | ||
| propDefinition: [ | ||
| grain, | ||
| "recordingId", | ||
| ], | ||
| }, | ||
| syncDir: { | ||
| type: "dir", | ||
| accessMode: "write", | ||
| sync: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.grain.downloadRecording({ | ||
| $, | ||
| recordingId: this.recordingId, | ||
| responseType: "arraybuffer", | ||
| returnFullResponse: true, | ||
| }); | ||
|
|
||
| const contentType = response.headers["content-type"]; | ||
| const extension = EXTENSION_BY_CONTENT_TYPE[contentType] ?? DEFAULT_EXTENSION; | ||
| const filename = `grain-recording-${this.recordingId}.${extension}`; | ||
| const filePath = `${process.env.STASH_DIR || "/tmp"}/${filename}`; | ||
|
|
||
| fs.writeFileSync(filePath, Buffer.from(response.data)); | ||
|
|
||
| $.export("$summary", `Downloaded recording ${this.recordingId} (${filename})`); | ||
| return { | ||
| filePath, | ||
| filename, | ||
| contentType, | ||
| }; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
components/grain/actions/list-meeting-types/list-meeting-types.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import grain from "../../grain.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "grain-list-meeting-types", | ||
| name: "List Meeting Types", | ||
| description: "Lists the meeting types configured in your Grain workspace (id, name, scope), where scope is `internal` or `external`." | ||
| + " Use this to understand how recordings are categorized, or to resolve a meeting type's ID for filtering." | ||
| + " Example: returns `[{\"id\": \"e8b894a9-7ecf-4330-a282-527c085618fd\", \"name\": \"Sales\", \"scope\": \"external\"}, {\"id\": \"815747d1-9e25-40f6-a3b8-e1908e25151e\", \"name\": \"1:1s\", \"scope\": \"internal\"}]`." | ||
| + " [See the documentation](https://developers.grain.com/#list-meeting-types)", | ||
| version: "0.0.1", | ||
| ai: "optimized", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| grain, | ||
| }, | ||
| async run({ $ }) { | ||
| const { meeting_types: meetingTypes } = await this.grain.listMeetingTypes({ | ||
| $, | ||
| }); | ||
|
|
||
| $.export("$summary", `Found ${meetingTypes.length} meeting type${meetingTypes.length === 1 | ||
| ? "" | ||
| : "s"}`); | ||
| return meetingTypes; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import grain from "../../grain.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "grain-list-teams", | ||
| name: "List Teams", | ||
| description: "Lists the teams in your Grain workspace (id, name)." | ||
| + " Use this to resolve a team's ID before sharing a recording with it via **Manage Recording Sharing**." | ||
| + " Example: returns `[{\"id\": \"a414c333-c9fe-4fdc-9131-fb31796699b2\", \"name\": \"Pipedream\"}]`." | ||
| + " [See the documentation](https://developers.grain.com/#list-teams)", | ||
| version: "0.0.1", | ||
| ai: "optimized", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| grain, | ||
| }, | ||
| async run({ $ }) { | ||
| const { teams } = await this.grain.listTeams({ | ||
| $, | ||
| }); | ||
|
|
||
| $.export("$summary", `Found ${teams.length} team${teams.length === 1 | ||
| ? "" | ||
| : "s"}`); | ||
| return teams; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import grain from "../../grain.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "grain-list-users", | ||
| name: "List Users", | ||
| description: "Lists the users in your Grain workspace (id, name, email)." | ||
| + " Use this to resolve a user's ID before sharing a recording with them via **Manage Recording Sharing**, or to identify who's who when reviewing recording participants." | ||
| + " Example: returns `[{\"id\": \"d91b7ed0-a149-425c-9623-0664148e4fc1\", \"name\": \"Danny Archer\", \"email\": \"darcher@pipedream.com\"}]`." | ||
| + " [See the documentation](https://developers.grain.com/#list-users)", | ||
| version: "0.0.1", | ||
| ai: "optimized", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| grain, | ||
| }, | ||
| async run({ $ }) { | ||
| const { users } = await this.grain.listUsers({ | ||
| $, | ||
| }); | ||
|
|
||
| $.export("$summary", `Found ${users.length} user${users.length === 1 | ||
| ? "" | ||
| : "s"}`); | ||
| return users; | ||
| }, | ||
| }; |
83 changes: 83 additions & 0 deletions
83
components/grain/actions/manage-recording-sharing/manage-recording-sharing.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import grain from "../../grain.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "grain-manage-recording-sharing", | ||
| name: "Manage Recording Sharing", | ||
| description: "Shares or unshares a recording with a specific user or team." | ||
| + " Use **List Recordings** to find the recording's ID, and **List Users** or **List Teams** to resolve the target's ID." | ||
| + " Set `operation` to `share` to grant access or `unshare` to revoke it, and `targetType` to `user` or `team`." | ||
| + " Example: `recordingId: \"pppp6666-qq77-rr88-ss99-tttt00000000\", operation: \"share\", targetType: \"user\", targetId: \"d91b7ed0-a149-425c-9623-0664148e4fc1\"` shares the recording with that user and returns `{\"success\": true}`." | ||
| + " [See the documentation](https://developers.grain.com/#share-recording-to-a-team)", | ||
| version: "0.0.1", | ||
| ai: "optimized", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| grain, | ||
| recordingId: { | ||
| propDefinition: [ | ||
| grain, | ||
| "recordingId", | ||
| ], | ||
| }, | ||
| operation: { | ||
| type: "string", | ||
| label: "Operation", | ||
| description: "Whether to share or unshare the recording.", | ||
| options: [ | ||
| "share", | ||
| "unshare", | ||
| ], | ||
| }, | ||
| targetType: { | ||
| type: "string", | ||
| label: "Target Type", | ||
| description: "Whether the target is a user or a team.", | ||
| options: [ | ||
| "user", | ||
| "team", | ||
| ], | ||
| }, | ||
| targetId: { | ||
| type: "string", | ||
| label: "Target ID", | ||
| description: "The ID of the user (from **List Users**) or team (from **List Teams**) to share or unshare the recording with.", | ||
|
michelle0927 marked this conversation as resolved.
Outdated
|
||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if (this.operation === "share") { | ||
| await this.grain.shareRecording({ | ||
| $, | ||
| recordingId: this.recordingId, | ||
| targetType: this.targetType, | ||
| data: { | ||
| [`${this.targetType}_id`]: this.targetId, | ||
| }, | ||
| }); | ||
| } else { | ||
| await this.grain.unshareRecording({ | ||
| $, | ||
| recordingId: this.recordingId, | ||
| targetType: this.targetType, | ||
| targetId: this.targetId, | ||
| }); | ||
| } | ||
|
|
||
| const summary = `${this.operation === "share" | ||
| ? "Shared" | ||
| : "Unshared"} recording ${this.recordingId} ${this.operation === "share" | ||
| ? "with" | ||
| : "from"} ${this.targetType} ${this.targetId}`; | ||
| $.export("$summary", summary); | ||
| return { | ||
| recordingId: this.recordingId, | ||
| operation: this.operation, | ||
| targetType: this.targetType, | ||
| targetId: this.targetId, | ||
| }; | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.