Skip to content
Back to skills

Functions

ASecurity

Turn the fixed run of MCP calls in one local skill into a tested saved function of toolscript-mcp, and change that skill to call it with one run_code. Use when the person names a skill with many MCP steps, or runs /toolscript:functions.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentsjavascriptgojavashellnodegit

Works with

  • claude code
  • cli
  • mcp

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add yeeyon/toolscript-mcp --skill functions --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Functions?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Functions
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/yeeyon-functions/badge)](https://www.skillsdirectory.com/skills/yeeyon-functions)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: functions
description: Turn the fixed run of MCP calls in one local skill into a tested saved function of toolscript-mcp, and change that skill to call it with one run_code. Use when the person names a skill with many MCP steps, or runs /toolscript:functions.
argument-hint: "<skill name>"
---

# toolscript-mcp functions

This skill reads one local skill of the person. It finds a run of MCP calls in a fixed order and drafts a saved function for that run. It drafts new skill text that calls the function with one `run_code`.
The skill tests the function with `functions check` and `functions try`. The person approves a diff, and then the skill writes two files.
A function with the line `skill: off` gets no skill of its own, so the local skill stays the one entry point. Each command here prints no secret value.

## Rules

- Before a step that writes a file, show the files and ask the person. Only step 9 writes the two target files. The files of the trial in step 7, inside the private folder `<work>`, are the one exception.
- Never read, print or edit the toolscript-mcp config file, and never run `init --dry-run`. Both show the env and header values of the servers.
- Never read `~/.claude.json`. Never list or scan a skills folder. Read only the one named skill file.
- Write each path in full, with forward slashes, also on Windows. Put each path in double quotes.
- Run each command of this skill as its own shell call. Never join two with `&&`, `;` or a pipe, so that each output and exit code is read on its own.
- Never write a policy rule. Never run `login` or `skills export`. Never use `run_code` for a trial.
- Write the two target files with the Write or Edit tool of this client. Never write them with `run_code`, Workspace or a bridge.
- If a command fails, show its output and stop. The commands of step 7 are the exception: they follow the rules of step 7. Delete `<work>` first, if you made it. Do not change a step to work around the failure.

The names in the commands:

- Each `toolscript-mcp` command here reads the default config. If the person says that the server runs with another config file, add `--config "<that path>"` to each command.
- `<work>` is a new private folder of the trial. Make it in step 7 with `node -p "require('fs').mkdtempSync(require('path').join(require('os').tmpdir(), 'toolscript-function-')).split(require('path').sep).join('/')"`. Only its owner can use it.
- `<home>` is the output of `node -p "require('os').homedir()"`.
- `<skill>` is the name of the local skill, and `<name>` is the name of the function.

## 1. Find the state

Look at the tools of this session. The session has toolscript-mcp when it lists the two tools `mcp__<key>__run_code` and `mcp__<key>__search_tools` with the same `<key>`. Use that key in the names of the tools. The scope of the entry does not matter: user, project or a `--mcp-config` file.

If the pair is missing, tell the person that this session has no toolscript-mcp. Tell the person to run `/toolscript:setup` and then to start a new Claude Code session. Stop.
Do not read the toolscript-mcp config file, and do not run `claude mcp get`.

## 2. Prove the package

Run `npx -y toolscript-mcp --version`. If it prints a version below 1.1.1, tell the person to run `/toolscript:setup update`, and stop.
Nothing is written. An older package has no `functions check` and no `functions try`.
If the update still gives a version below 1.1.1, the new package is not on npm yet. Tell the person to wait for it, and stop.

## 3. Find the one skill

The person names one skill. With no name, ask for one and stop. Never list or scan a skills folder to find a skill.

- The name has 1 to 64 characters: letters, digits, `-` and `_`. Otherwise stop.
- Refuse a name that starts with `toolscript-`. The export owns those folders. Refuse `setup`, `start`, `doctor`, `workspace` and `functions`, the skills of this plugin.
- Refuse a skill of a plugin. Never read the plugin cache.
- Run `node -p "process.env.CLAUDE_CONFIG_DIR || require('os').homedir() + '/.claude'"` and `node -p "process.cwd()"`. These two commands hold no path.
- Check the two outputs before any command uses them. Stop if one holds `$`, a backtick, `"`, `%`, `!`, a curly quote or a long dash. A shell can change such a path, and a command in double quotes can run it.
- The user skill is `<the first output>/skills/<skill>/SKILL.md`. The project skill is `<the second output>/.claude/skills/<skill>/SKILL.md`.
- Run `node -e "const fs = require('fs'); for (const p of process.argv.slice(1)) { if (!fs.existsSync(p)) { console.log(p, 'missing'); continue } const s = fs.lstatSync(p); console.log(p, 'present', s.isSymbolicLink(), s.size) }" "<user folder>" "<user file>" "<project folder>" "<project file>"`.
- If neither file exists, say so and stop. Do not search for the skill. Never list or scan a folder.
- If both files exist, ask which one. For a project skill, tell the person that the repository shares the file.
- Stop if the folder or the file is a link or a junction, or if the file is larger than 65,536 bytes.
- Read only that one file with the Read tool.

## 4. The fit test

Tell the person the test before any draft. A fit is a run of 2 or more MCP tool calls in a fixed order. Each call takes its input from the arguments of the person or from an earlier result. No judgment is between the calls.

Not a fit:

- One call or none.
- Steps that are only shell, file or web tools.
- A step that already names `lib.`.
- Tools of a server whose key `npx -y toolscript-mcp tools "<key>"` does not find in the config.

For a skill that is not a fit, say why in 1 to 3 sentences, write nothing and stop.

A judgment between calls splits the steps. The function covers one run of calls on one side of a judgment point. The judgment, the trigger, the questions to the person and every step that is not an MCP call stay as text, in their place.
Make one function for each run of the skill. If the skill has more than one run, ask which run to convert. The default is the first run. The person can run this skill again for the next run.

## 5. Draft the function

Use these tool names only: the names that `npx -y toolscript-mcp tools "<key>"` printed. Never guess a tool or an argument name.
Never guess the shape of a result either. When the skill text does not give it, the first trial of step 7 is a probe: the same file, with code that returns the raw result of the first call, such as `return await call("mcp__<key>__<tool>", {})`. `functions try` prints the result. Then write the full code from that shape. The probe is one of the 3 trials.

- `<name>` is a JavaScript name of 40 characters at most, such as `releaseDigest`.
- `description` is one line of 200 characters at most. It says the job and the fact that makes it hard. `search_tools` shows it.
- Add the line `skill: off` after `description`. Then toolscript-mcp serves no `toolscript:<name>` skill and no `more-hints` entry for it, and `skills export` skips it.
- The code is one async function with one object parameter. Name each tool as a literal string in `call("mcp__<key>__<tool>", ...)`.
- Ids, keys, project names, queries and dates of the skill text become parameters of that object.
- The code holds no data of the person. If a step holds a literal that looks like a token, a password or a key, stop. Tell the person which line.

The file has this form:

````md
---
name: releaseDigest
description: One line: the job, and the fact that makes it hard.
skill: off
---

```js
async ({ count }) => {
  // the calls, each as call("mcp__<key>__<tool>", { ... })
}
```
````

## 6. Draft the new skill text

Replace only the steps of the run. Keep the frontmatter and every line outside the replaced steps byte-equal. Put no code of the function in the skill.
The replaced steps become one block. Label it with the numbers of the replaced steps, such as `2-3.`, so that the next steps keep their numbers. For a bullet list, use the bullet.

````md
2-3. Run the saved function with the `run_code` tool of toolscript-mcp. Use this call, with each `…` replaced by the value from the steps above:

   ```js
   return await lib.<name>({ count: … })
   ```

   If this session has no `run_code` tool of toolscript-mcp, tell the person that toolscript-mcp is not connected, and stop. Do not rebuild the program from memory.
````

The call names the parameters of the function. The old steps are removed, with no fallback copy and no backup file.

## 7. Trial

Make the private folder `<work>`. Write the draft to `<work>/<name>.md`. Write the arguments of the trial, one JSON object, to `<work>/args.json`. Never use a fixed name in a shared temp folder.

1. Show the tools that the code names, the argument values and whether `--writes` is needed. Ask the person to go on.
2. Pass `--writes` only when the person says so in words for these tools. Without it, a function that names a tool that is not read-only is not run.
3. Run `npx -y toolscript-mcp functions check "<work>/<name>.md"`. It must print `description: skill off`. If it does not, the draft is wrong. Fix the draft before the trial.
4. Run `npx -y toolscript-mcp functions try "<work>/<name>.md" --args "<work>/args.json"`. If the person said so in words for these tools, add `--writes` to that command.

Show a failed trial as printed. Then fix the draft from what the trial printed, and run the next trial. Run at most 3 trials for one run of the skill. After the third, stop with nothing written.
A trial that did not run is "not run". An `ask` tool, a write with no flag or a login is such a case. Give the reason and the two choices: allow the tool with `/toolscript:start` step 5, or approve with no trial. Never call it a pass.

At the end of this skill, on every path, delete the folder `<work>` with `node -e "require('fs').rmSync(process.argv[1], { recursive: true, force: true })" "<work>"`.

## 8. Approval

Show all of this in one message:

- The whole function file.
- A unified diff of the skill text.
- The result line of the trial.
- One line: `skill: off` keeps the local skill the only entry point.
- The two full target paths.

Ask one question, with the default no. Anything but a clear yes writes nothing.

## 9. Write

After a yes, write exactly two files with the Write or Edit tool. Write the function file first.

- The function file is `<home>/.toolscript-mcp/functions/<name>.md`. It must not exist. Check with `node -e "console.log(require('fs').existsSync(process.argv[1]))" "<file>"`. Never overwrite a function file.
- The second file is the named `SKILL.md`, with the text that the person approved.
- If the second write fails, say which file exists and how to remove it.

## 10. Check the result

Run `npx -y toolscript-mcp functions check "<home>/.toolscript-mcp/functions/<name>.md"`. Its `sha256` line must equal the `sha256` line of the trial.
If the hash differs, say that the check failed and name the file to delete. Then read the `SKILL.md` again with the Read tool and compare it with the text that the person approved.

## 11. Last message

Say these things:

- The two paths.
- A new session loads the new skill text.
- How to undo: delete the function file, and put the old steps back from the diff or from git.
- The local skill is the only entry point. Without the line `skill: off` in the function file, toolscript-mcp adds a second skill, `toolscript:<name>`.

This skill runs no `skills export`, writes no policy rule and runs no `login`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.