mastra/Getting Started

Build with AI

Tools and patterns for building AI-powered applications

aiskillsmcpgetting-started

Build with AI

Tools and patterns for building AI-powered applications.

Topics

Skills

Reusable AI capabilities that can be shared and composed.

What are Skills?

Skills are pre-packaged AI capabilities that:

  • Encapsulate commonly used patterns
  • Can be composed together
  • Are easily shareable across projects
  • Include prompts, tools, and configurations

Built-in Skills

import { skills } from '@mastra/core';

// Get a built-in skill
const codeReviewSkill = skills.get('code-review');
const summarizationSkill = skills.get('summarization');

Creating Skills

import { Skill } from '@mastra/core';

const mySkill = new Skill({
  name: 'my-custom-skill',
  description: 'Does something useful',
  version: '1.0.0',

  // Prompts
  systemPrompt: 'You are a helpful assistant...',
  fewShotExamples: [
    { input: 'Hello', output: 'Hi there!' },
  ],

  // Tools
  tools: [tool1, tool2],

  // Configuration
  defaultOptions: {
    temperature: 0.7,
    maxTokens: 1000,
  },
});

Using Skills

const agent = new Agent({
  name: 'my-agent',
  skills: [codeReviewSkill, mySkill],
});

Publishing Skills

  1. Create a skill package
  2. Test thoroughly
  3. Publish to npm
  4. Share with the community

MCP Docs Server

Document your MCP server for agents and users.

Overview

MCP Docs Server generates documentation for your MCP server's resources, tools, and prompts.

Creating a Docs Server

import { createDocsServer } from '@mastra/mcp';

const docsServer = createDocsServer({
  name: 'my-mcp-docs',
  server: myMCPServer,
  options: {
    includeResources: true,
    includeTools: true,
    includePrompts: true,
  },
});

Documentation Format

// Generated docs structure
{
  name: 'my-mcp-docs',
  resources: [
    {
      name: 'docs',
      description: 'API Documentation',
      uri: 'docs://api',
    },
  ],
  tools: [
    {
      name: 'search',
      description: 'Search documentation',
      inputSchema: { type: 'object', properties: {...} },
    },
  ],
}

API Documentation

docsServer.generateAPIDocs({
  format: 'openapi', // or 'asyncapi', 'json-schema'
  output: './docs/api.yaml',
});

Usage

Agents can query the docs server to understand available capabilities:

const capabilities = await docsServer.getCapabilities();
console.log(capabilities.tools);
console.log(capabilities.resources);