<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hammerspace MCP - Natural Language Interface</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
width: 100%;
max-width: 1200px;
height: 90vh;
display: flex;
flex-direction: column;
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
color: white;
padding: 25px 30px;
border-radius: 20px 20px 0 0;
}
.header h1 {
font-size: 24px;
font-weight: 600;
margin-bottom: 5px;
}
.header p {
font-size: 14px;
opacity: 0.9;
}
.tools-bar {
background: #f7f9fc;
padding: 15px 30px;
border-bottom: 1px solid #e1e8ed;
display: flex;
justify-content: space-between;
align-items: center;
}
.tools-count {
font-size: 14px;
color: #666;
}
.action-buttons {
display: flex;
gap: 10px;
}
.btn {
color: white;
border: none;
padding: 8px 16px;
border-radius: 8px;
cursor: pointer;
font-size: 14px;
transition: all 0.2s;
text-decoration: none;
display: inline-flex;
align-items: center;
gap: 6px;
}
.monitor-btn {
background: #1e3a8a;
}
.monitor-btn:hover {
background: #1e40af;
transform: translateY(-1px);
}
.debug-btn {
background: #3b82f6;
}
.debug-btn:hover {
background: #2563eb;
transform: translateY(-1px);
}
.events-btn {
background: #1e3a8a;
}
.events-btn:hover {
background: #1e40af;
transform: translateY(-1px);
}
.mcp-btn {
background: #7c3aed;
}
.mcp-btn:hover {
background: #6d28d9;
transform: translateY(-1px);
}
.clear-btn {
background: #ff4757;
}
.clear-btn:hover {
background: #ff3838;
transform: translateY(-1px);
}
.chat-container {
flex: 1;
overflow-y: auto;
padding: 30px;
background: #f7f9fc;
}
.message {
margin-bottom: 20px;
display: flex;
animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.message.user {
justify-content: flex-end;
}
.message-content {
max-width: 70%;
padding: 15px 20px;
border-radius: 18px;
line-height: 1.5;
word-wrap: break-word;
position: relative;
}
.copy-btn {
position: absolute;
top: 8px;
right: 8px;
background: rgba(0, 0, 0, 0.1);
border: none;
border-radius: 6px;
padding: 6px 10px;
cursor: pointer;
font-size: 12px;
opacity: 0;
transition: all 0.2s;
color: inherit;
}
.message-content:hover .copy-btn {
opacity: 1;
}
.copy-btn:hover {
background: rgba(0, 0, 0, 0.2);
}
.copy-btn:active {
background: rgba(0, 0, 0, 0.3);
}
.copy-btn.copied {
background: #4caf50;
color: white;
opacity: 1;
}
.message.user .message-content {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-bottom-right-radius: 4px;
}
.message.assistant .message-content {
background: white;
color: #333;
border: 1px solid #e1e8ed;
border-bottom-left-radius: 4px;
}
.message.system .message-content {
background: #fff3cd;
color: #856404;
border: 1px solid #ffeaa7;
max-width: 90%;
margin: 0 auto;
text-align: center;
font-size: 14px;
}
.input-container {
padding: 25px 30px;
background: white;
border-top: 1px solid #e1e8ed;
display: flex;
gap: 15px;
}
#messageInput {
flex: 1;
padding: 15px 20px;
border: 2px solid #e1e8ed;
border-radius: 12px;
font-size: 15px;
transition: all 0.2s;
font-family: inherit;
}
#messageInput:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
#sendButton {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 15px 30px;
border-radius: 12px;
cursor: pointer;
font-size: 15px;
font-weight: 600;
transition: all 0.2s;
min-width: 120px;
}
#sendButton:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
#sendButton:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.typing-indicator {
display: none;
padding: 15px 20px;
background: white;
border: 1px solid #e1e8ed;
border-radius: 18px;
border-bottom-left-radius: 4px;
width: fit-content;
}
.typing-indicator.active {
display: block;
}
.typing-indicator span {
height: 8px;
width: 8px;
background: #667eea;
border-radius: 50%;
display: inline-block;
margin-right: 5px;
animation: bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) {
animation-delay: -0.32s;
}
.typing-indicator span:nth-child(2) {
animation-delay: -0.16s;
}
@keyframes bounce {
0%, 80%, 100% {
transform: scale(0);
opacity: 0.5;
}
40% {
transform: scale(1);
opacity: 1;
}
}
.example-prompts {
padding: 20px;
background: #e8f4fd;
border-radius: 12px;
margin-bottom: 20px;
}
.example-prompts h3 {
color: #2c5aa0;
font-size: 16px;
margin-bottom: 12px;
}
.example-prompts ul {
list-style: none;
}
.example-prompts li {
padding: 8px 0;
color: #5a7fb5;
font-size: 14px;
cursor: pointer;
transition: all 0.2s;
}
.example-prompts li:hover {
color: #2c5aa0;
padding-left: 10px;
}
.example-prompts li:before {
content: "💬 ";
margin-right: 8px;
}
pre {
background: #f4f4f4;
padding: 10px;
border-radius: 8px;
overflow-x: auto;
font-size: 13px;
margin: 10px 0;
}
code {
font-family: 'Courier New', monospace;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🔧 Hammerspace MCP Control Center</h1>
<p>Hammerspace Workflow Console powered by NVIDIA + MCP Services</p>
</div>
<div class="tools-bar">
<div class="tools-count" id="toolsCount">Loading tools...</div>
<div class="action-buttons">
<a href="/monitor" class="btn monitor-btn" target="_blank">📊 Monitor</a>
<a href="/debug" class="btn debug-btn" target="_blank">🐛 Debug</a>
<a href="/events" class="btn events-btn" target="_blank">📡 Events</a>
<a href="/mcp" class="btn mcp-btn" target="_blank">🔧 MCP Control</a>
<button class="btn clear-btn" onclick="clearChat()">🗑️ Clear Chat</button>
</div>
</div>
<div class="chat-container" id="chatContainer">
<div class="example-prompts">
<h3>Try these commands:</h3>
<ul>
<li onclick="sendExample(this)">Tag all files in /modelstore/nvidia-test-thurs as modelsetid=mynvidiademo</li>
<li onclick="sendExample(this)">Promote all modelsetid=mynvidiademo tagged files to tier0</li>
<li onclick="sendExample(this)">Check alignment status of files tagged with modelsetid=mynvidiademo</li>
<li onclick="sendExample(this)">Remove the Place-on-tier0 objective from /modelstore/nvidia-test-thurs</li>
<li onclick="sendExample(this)">List all objectives for /modelstore/gtc-demo-models/</li>
<li onclick="sendExample(this)">Get file monitor status (auto-tagging service)</li>
<li onclick="sendExample(this)">Refresh Hammerspace mounts</li>
<li onclick="sendExample(this)">Show Milvus database status and collections</li>
<li onclick="sendExample(this)">Check Kubernetes cluster status and running pods</li>
<li onclick="sendExample(this)">List all MCP server status</li>
</ul>
</div>
</div>
<div class="input-container">
<input
type="text"
id="messageInput"
placeholder="Type your command in natural language..."
onkeypress="handleKeyPress(event)"
/>
<button id="sendButton" onclick="sendMessage()">Send</button>
</div>
</div>
<script>
let isProcessing = false;
async function loadTools() {
try {
const response = await fetch('/api/tools');
const data = await response.json();
const toolsCount = data.tools.length;
document.getElementById('toolsCount').textContent = `${toolsCount} MCP tools available`;
} catch (error) {
console.error('Error loading tools:', error);
document.getElementById('toolsCount').textContent = 'Error loading tools';
}
}
function addMessage(content, type) {
const chatContainer = document.getElementById('chatContainer');
const messageDiv = document.createElement('div');
messageDiv.className = `message ${type}`;
const contentDiv = document.createElement('div');
contentDiv.className = 'message-content';
// Format content (preserve line breaks, parse JSON)
if (type === 'assistant') {
try {
// Try to parse as JSON for pretty printing
const jsonMatch = content.match(/\{[\s\S]*\}/);
if (jsonMatch) {
const beforeJson = content.substring(0, jsonMatch.index);
const afterJson = content.substring(jsonMatch.index + jsonMatch[0].length);
const jsonObj = JSON.parse(jsonMatch[0]);
contentDiv.innerHTML = beforeJson + '<pre><code>' +
JSON.stringify(jsonObj, null, 2) + '</code></pre>' + afterJson;
} else {
contentDiv.textContent = content;
}
} catch (e) {
contentDiv.textContent = content;
}
} else {
contentDiv.textContent = content;
}
// Add copy button
const copyBtn = document.createElement('button');
copyBtn.className = 'copy-btn';
copyBtn.textContent = '📋 Copy';
copyBtn.onclick = function(e) {
e.stopPropagation();
copyToClipboard(content, copyBtn);
};
contentDiv.appendChild(copyBtn);
messageDiv.appendChild(contentDiv);
chatContainer.appendChild(messageDiv);
chatContainer.scrollTop = chatContainer.scrollHeight;
}
function copyToClipboard(text, button) {
// Try modern clipboard API first
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(() => {
const originalText = button.textContent;
button.textContent = '✓ Copied!';
button.classList.add('copied');
setTimeout(() => {
button.textContent = originalText;
button.classList.remove('copied');
}, 2000);
}).catch(err => {
console.error('Clipboard API failed:', err);
fallbackCopy(text, button);
});
} else {
// Fallback for older browsers or non-secure contexts
fallbackCopy(text, button);
}
}
function fallbackCopy(text, button) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.left = '-999999px';
textArea.style.top = '-999999px';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
const successful = document.execCommand('copy');
document.body.removeChild(textArea);
if (successful) {
const originalText = button.textContent;
button.textContent = '✓ Copied!';
button.classList.add('copied');
setTimeout(() => {
button.textContent = originalText;
button.classList.remove('copied');
}, 2000);
} else {
button.textContent = '✗ Failed';
setTimeout(() => {
button.textContent = '📋 Copy';
}, 2000);
}
} catch (err) {
console.error('Fallback copy failed:', err);
document.body.removeChild(textArea);
button.textContent = '✗ Failed';
setTimeout(() => {
button.textContent = '📋 Copy';
}, 2000);
}
}
function showTypingIndicator() {
const chatContainer = document.getElementById('chatContainer');
const indicator = document.createElement('div');
indicator.className = 'message assistant';
indicator.id = 'typingIndicator';
indicator.innerHTML = '<div class="typing-indicator active"><span></span><span></span><span></span></div>';
chatContainer.appendChild(indicator);
chatContainer.scrollTop = chatContainer.scrollHeight;
}
function hideTypingIndicator() {
const indicator = document.getElementById('typingIndicator');
if (indicator) {
indicator.remove();
}
}
async function sendMessage() {
if (isProcessing) return;
const input = document.getElementById('messageInput');
const message = input.value.trim();
if (!message) return;
isProcessing = true;
document.getElementById('sendButton').disabled = true;
// Add user message to chat
addMessage(message, 'user');
input.value = '';
// Show typing indicator
showTypingIndicator();
try {
const response = await fetch('/api/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: message })
});
const data = await response.json();
hideTypingIndicator();
if (data.error) {
addMessage('Error: ' + data.error, 'system');
} else {
addMessage(data.response, 'assistant');
}
} catch (error) {
hideTypingIndicator();
addMessage('Error: ' + error.message, 'system');
} finally {
isProcessing = false;
document.getElementById('sendButton').disabled = false;
input.focus();
}
}
function handleKeyPress(event) {
if (event.key === 'Enter' && !isProcessing) {
sendMessage();
}
}
function sendExample(element) {
const input = document.getElementById('messageInput');
input.value = element.textContent;
input.focus();
}
async function clearChat() {
if (confirm('Clear conversation history?')) {
try {
await fetch('/api/clear', { method: 'POST' });
document.getElementById('chatContainer').innerHTML = `
<div class="example-prompts">
<h3>Try these commands:</h3>
<ul>
<li onclick="sendExample(this)">Tag all files in /modelstore/nvidia-test-thurs as modelsetid=mynvidiademo</li>
<li onclick="sendExample(this)">Promote all modelsetid=mynvidiademo tagged files to tier0</li>
<li onclick="sendExample(this)">Check alignment status of files tagged with modelsetid=mynvidiademo</li>
<li onclick="sendExample(this)">Remove the Place-on-tier0 objective from /modelstore/nvidia-test-thurs</li>
<li onclick="sendExample(this)">List all objectives for /modelstore/gtc-demo-models/</li>
<li onclick="sendExample(this)">Get file monitor status (auto-tagging service)</li>
<li onclick="sendExample(this)">Refresh Hammerspace mounts</li>
<li onclick="sendExample(this)">Show Milvus database status and collections</li>
<li onclick="sendExample(this)">Check Kubernetes cluster status and running pods</li>
<li onclick="sendExample(this)">List all MCP server status</li>
</ul>
</div>
`;
} catch (error) {
console.error('Error clearing chat:', error);
}
}
}
// Load tools on page load
loadTools();
// Focus on input
document.getElementById('messageInput').focus();
</script>
</body>
</html>