Gungnir API Reference

Comprehensive documentation for Gungnir SDK Core, CLI, and MCP Server implementation

Documentation
Getting Started
Installation
Quick Start Guide
Gungnir SDK Core
GungnirCore
GungnirPlugin
Types
Gungnir CLI
Commands
Configuration
MCP Server
Endpoints
Tool Definitions
Authentication
Getting Started with Gungnir
Learn how to install and use the Gungnir SDK Core and CLI
Installation
# Install Gungnir SDK Core npm install @gungnir/core # Install Gungnir CLI npm install -g gungnir-cli

Basic Usage

TypeScript
import { GungnirCore } from '@gungnir/core';

const gungnir = new GungnirCore({ version: '1.0.0' });
gungnir.initialize();

const result = gungnir.process({ data: 'example' });
CLI
# Configure your Perplexity API key
gungnir config set perplexity_api_key your_api_key

# Run an MCP task with a prompt
gungnir run mcp-task --prompt "Create a weather API server"
Gungnir SDK Core API
Core library for working with MCP servers

GungnirCore

The main class for interacting with Gungnir functionality.

constructor(config: GungnirConfig)

Creates a new instance of the GungnirCore class.

ParameterTypeDescription
configGungnirConfigConfiguration object for Gungnir
initialize(): void

Initializes the Gungnir core functionality.

Returns: void

process(data: any): any

Process data with Gungnir.

ParameterTypeDescription
dataanyThe data to process

Returns: Processed data result

Types

GungnirConfig

Configuration for the Gungnir core.

PropertyTypeDescription
versionstringVersion string
optionsRecord<string, any>Optional configuration options
GungnirResult

Standard result object for Gungnir operations.

PropertyTypeDescription
successbooleanWhether the operation was successful
dataanyOptional result data
errorstringOptional error message
timestampDateTimestamp of the result
Gungnir CLI Reference
Command-line interface for Gungnir

Commands

gungnir config

Manage Gungnir CLI configuration.

Subcommands

gungnir config set <key> <value>

Set a configuration key-value pair.

gungnir config get [key]

Get a configuration value. Shows all if no key is specified.

gungnir config show_path

Shows the path to the configuration file.

gungnir run mcp-task

Run an MCP server task based on a prompt.

Options

OptionDescription
--prompt TEXTNatural language description of the MCP server to generate
--output-dir TEXTDirectory to output the generated files
--model TEXTModel to use for generation
gungnir sonar

Interact with Perplexity Sonar API.

Options

OptionDescription
--query TEXTQuery to send to Sonar API
--model TEXTModel to use for the Sonar API
MCP Server API Reference
API endpoints for generated MCP servers
GET /api/v1/models

Lists all available models supported by the server.

Response

{ "data": [ { "id": "gpt-4o", "owned_by": "openai" }, { "id": "claude-3-opus", "owned_by": "anthropic" } ] }
POST /api/v1/chat/completions

Generates completions from a chat conversation.

Request

{ "model": "gpt-4o", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What's the weather in San Francisco?" } ], "tools": [ { "name": "get_weather", "description": "Get current weather for a location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "City name" } }, "required": ["location"] } } ] }

Response

{ "id": "chatcmpl-abc123", "object": "chat.completion", "created": 1677858242, "model": "gpt-4o", "choices": [ { "message": { "role": "assistant", "content": null, "tool_calls": [ { "id": "call_abc123", "type": "function", "function": { "name": "get_weather", "arguments": "{\"location\": \"San Francisco\"}" } } ] }, "finish_reason": "tool_calls" } ] }
POST /api/v1/execute

Executes a tool call with the provided parameters.

Request

{ "tool": "get_weather", "params": { "location": "San Francisco, CA" } }

Response

{ "result": { "temperature": 65, "condition": "Partly Cloudy", "humidity": 75, "wind": "8 mph" } }